I am trying to un-marshall an xml, which is turning out to be nightmare with lot of issues. So I got an idea to unmarshall part of this xml to an object which is necessary for me.
Original xml: http://snipurl.com/24qkyi7
now what I need from this xml is: http://snipurl.com/24qkyyl
I have classes and other related info of both xmls.
If I manually give this data http://snipurl.com/24ql04x to unmarshall, i am getting StandardError object. But can i give original xml directly to get this object out of it.
ps: Using JAXB
Stack trace of original xml parsing: http://snipurl.com/24qtrnv Class file of original xml class which I am failing to unmarshall. No source control on this http://snipurl.com/24qttn8
StandardError class: http://snipurl.com/24rpdld Main xml class: http://snipurl.com/24rpdxu
I would parser the XML using a StAX
XMLStreamReader
, and advance theXMLStreamReader
to the element that you wish to unmarshal. Then I would have JAXB unmarshal theXMLStreamReader
. Something like the following:Demo
StandardError
Below is the
StandardError
classpackage-info
I will use the
@XmlSchema
annotation on apackage-info
class to specify the namespace qualification for the classes in thebgc.objects.rosy.standarderror.v3
package.Output
Below is the output from running the demo code:
For More Information