Constantine Gladky Constantine Gladky - 1 year ago 118
Java Question

How to marshall JAXBElement<Object> into org.w3c.dom.Element in Java using JAXB

I need to get Element object with request. I have ObjectFactory. I created an JAXBElement, and I need to marshall it to Element. Could anyone help me?

Answer Source

You could marshal to a DOMResult:

DOMResult res = new DOMResult();
marshaller.marshal(myJaxbElement, res);
Element elt = ((Document)res.getNode()).getDocumentElement();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download