Hi,
I am able to get the root element with the follwoing approach with uses JAXB with Stax parser.
But It is working for getting the rool element of XML.but if we want to get the child element it is returning Object with null values.
Example
<foo>
<xyz>
<abc></abc>
</xyz>
</foo>
SO now I can create foo obect correctly , but I am not able to create xyz or abc objects.
For root I did like this.
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" ); //created context to work with root node
Unmarshaller unmarshaller= jc.createUnmarshaller();
javax.xml.stream.XMLStreamReader xmlStreamReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
JAXBElement root = unmarshaller.unmarshal(xmlStreamReader,com.acme.foo.class);
com.acme.Foo foo= root.getValue()
for abc I did like this
JAXBContext jc = JAXBContext.newInstance( "com.acme.abc" ); //created context to work with child node
Unmarshaller unmarshaller= jc.createUnmarshaller();
javax.xml.stream.XMLStreamReader xmlStreamReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
JAXBElement root = unmarshaller.unmarshal(xmlStreamReader,com.acme.abc.class);
com.acme.abc foo= root.getValue()
This code is not working.
Can some once help in getting the child elemntby calling unmarshalling.
I am able to get the root element with the follwoing approach with uses JAXB with Stax parser.
But It is working for getting the rool element of XML.but if we want to get the child element it is returning Object with null values.
Example
<foo>
<xyz>
<abc></abc>
</xyz>
</foo>
SO now I can create foo obect correctly , but I am not able to create xyz or abc objects.
For root I did like this.
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" ); //created context to work with root node
Unmarshaller unmarshaller= jc.createUnmarshaller();
javax.xml.stream.XMLStreamReader xmlStreamReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
JAXBElement root = unmarshaller.unmarshal(xmlStreamReader,com.acme.foo.class);
com.acme.Foo foo= root.getValue()
for abc I did like this
JAXBContext jc = JAXBContext.newInstance( "com.acme.abc" ); //created context to work with child node
Unmarshaller unmarshaller= jc.createUnmarshaller();
javax.xml.stream.XMLStreamReader xmlStreamReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
JAXBElement root = unmarshaller.unmarshal(xmlStreamReader,com.acme.abc.class);
com.acme.abc foo= root.getValue()
This code is not working.
Can some once help in getting the child elemntby calling unmarshalling.