Link to home
Start Free TrialLog in
Avatar of JonMny
JonMny

asked on

Java XML updating xml doc with embedded dtd - dtd is lost when xml is updated

I have an XML document that has an embedded DTD.  I have a method that will update the value of an element passed and save the doc. When the doc is saved the element is updated as expected, however the embedded DTD is wiped out.  How do I preserve the DTD?

Node resultNode = findSubNode(elementName, mDoc.getDocumentElement());
            if (resultNode != null) {
                  resultNode.setTextContent(value);
                  Transformer xformer;
                  try {
                        xformer = TransformerFactory.newInstance().newTransformer();
                        xformer.transform(new DOMSource(mDoc), new StreamResult(new File(mXmlPath)));
                  } catch (Exception e) {
                        XmlError = e.getMessage();
                        return false;
                  }
                  return true;
            } else
                  return false;
      }
ASKER CERTIFIED SOLUTION
Avatar of aciuica
aciuica
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial