|
I am trying to get a DOM document to be then used with Xalan’s
XPathAPI. This is the code that I have: String xmlFile = "dom.xml"; XmlObject xmlObject = new XmlReader().read(xmlFile); DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance(); // MUST be TRUE or can't get back
to bean land factory.setNamespaceAware(true); DocumentBuilder builder =
factory.newDocumentBuilder(); // Switch to org.w3c.dom.Document
- xmlbeans.getDomNode() doesn't // really seem to give you this ByteArrayOutputStream out = new ByteArrayOutputStream(); xo.save(out,new
XmlOptions().setSavePrettyPrint()); Document doc = builder.parse(new InputSource(new
ByteArrayInputStream(out.toByteArray()))); NodeList nodes =
XPathAPI.selectNodeList(doc,"/Pipeline"); System.out.println("Number of nodes
is "
+ nodes.getLength()); DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance(); DocumentBuilder builder =
dbf.newDocumentBuilder(); Document doc1 = builder.parse( new File(xmlFile)); NodeList nodes1 = XPathAPI.selectNodeList(doc1,"/Pipeline"); System.out.println("Number of nodes
is "
+ nodes1.getLength()); I get two different answers in the system out. Any ideas as to
what could be wrong in creating a DOM document from a XMLBeans object? |
- XMLBeans DOM Document Mohana Ramaratnam
- RE: XMLBeans DOM Document Radu Preotiuc-Pietro

