I'm very new to JAXB. I have an XML doc which contains serialized object inside one of its element:
<?xml>
<structure>
...blah-blah
<serializedElement>
... JAXB xml block
</serializedElement>
</structure>
</xml>
How do I unmarshal such element?
I wrote the following:
org.w3c.dom.Document doc = db.parse(new StringInputStream(rawXml));
org.w3c.dom.Element obj = (org.w3c.dom.Element) doc.getElementsByTagName("serializedElement").item(0);
JAXBElement<MyJaxBObject> je = um.unmarshal(obj, MyJaxBObject.class);
System.out.println(je.getValue());
but this always return empty value object (although of correct class).
What am I doing wrong?
Thank you!
Ok, finally. The problem was in missing
dbf.setNamespaceAware(true);
After adding this line everything works fine.
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