Monday, 15 February 2010

java - JAXB: Can we access and assign the inner node tags in the parent class using jaxb unmarshaller -


Below is the XML I have that I want to use an object JAXB unmarshaller:

  & lt; Start & gt; & Lt; Name & gt; SSS & lt; / Name & gt; & Lt; Address & gt; & Lt; Street1 & gt; Xxx & lt; / Street1 & gt; & Lt; Street2 & gt; Yyy & lt; / Street2 & gt; & Lt; Zip & gt; 121,212 & lt; / Zip> & Lt; / Address & gt; & Lt; / Start & gt;  

Is there a possibility to reach and set zip in the initial class?
For the readability below, the root class for the above XML is, I am not completing the setters and the gates:

  pacakge com.data // import import package javax.xml .bind.annotation.XmlElement; Import javax.xml.bind.annotation.XmlRootElement; // Root element class declaration @ XMLRoot Element (name = "start") public class start {// element in XML personal string name; Private address addresses; Private int zip; @ XMLElement (name = "name") // set name @ xmlElement (name = "address") // Setters and getters @ namemlElement (name = "zip") for name tags for sets and gates // setters and getters Tag for zip public int getZip () {return zip; } Public Zero setZip (Int zip) {this.zip = zip; }}  

This can be achieved using EclipseLink and @XmlPath annotations < / P>


No comments:

Post a Comment