<productInfo>
<product>
<productPrice>
<price></price>
</productPrice>
</product>
<productInfo>
To create an XML like the above I am creating classes for productInfo, product, productPrice and then I am "unmarshalling" using JAXB annotations.
Is there any way to unmarshall without creating product class?
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.
You could use the @XmlPath extension in the MOXy implementation of JAXB to map this use case.
import javax.xml.bind.annotation.*;
import org.eclipse.persistence.oxm.annotations.XmlPath;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ProductInfo {
@XmlPath("product/productPrice/price/text()")
private double price;
}
For More Information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With