Constantine Gladky Constantine Gladky - 5 months ago 38
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?


You could marshal to a DOMResult:

DOMResult res = new DOMResult();
marshaller.marshal(myJaxbElement, res);
Element elt = ((Document)res.getNode()).getDocumentElement();