• Post Reply Bookmark Topic Watch Topic
  • New Topic

XML Entity reference  RSS feed

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

When i am adding some new nodes to an existing xml element everything seems fine but new document does not contain entity reference node.Can anybody tell me please why I loose entity reference although i dont make any processing with it ? Do i need to set some attribute not to loose it ?

here is my code;

doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("myxml.xml");

XPath xpath = XPathFactory.newInstance().newXPath();
NodeList nodes = (NodeList)xpath.evaluate("//A/B[@name='C']", doc, XPathConstants.NODESET);

Element entry = doc.createElement("entry");
Attr valueAttribute = doc.createAttribute("value");

// append attribute
// save the result
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(new DOMSource(doc), new StreamResult("myxml.xml"));

Thank you.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!