Is it possible to convert nu.XOM.Element
to org.w3c.dom.Element
?
Am trying to construct XML using XOM APIs. But few of my legacy APIs expects org.w3c.dom.Element
. So, I just want to know if I can convert.
Thank You :)
Is it possible to convert nu.XOM.Element
to org.w3c.dom.Element
?
Am trying to construct XML using XOM APIs. But few of my legacy APIs expects org.w3c.dom.Element
. So, I just want to know if I can convert.
Thank You :)
There is the nu.xom.converters.DOMConverter
class, which provides a way of translating an entire XOM document into a corresponding DOM document, but you can't do it for individual elements, probably because a W3C Element
can't exist without a parent Document
.
XOM Document:
final nu.xom.Element root = new nu.xom.Element("root");
root.appendChild("Hello World!");
final nu.xom.Document xomDoc = new nu.xom.Document(root);
using DOMConverter:
final DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final DOMImplementation impl = builder.getDOMImplementation();
final Document w3cDoc= DOMConverter.convert(xomDoc, impl);