Sunday, 8 February 2015

Create Header Elements with Java Xerces XML Creation



How can I add standard header statements to XML documents that I generate using Java Xerces?


Something like this:?



<?xml version="1.0" encoding="utf-8"?>
<!--My Comment for this XML File -->
<?TSMKey applanguage="EN" appversion="4.3.0" dtdversion="1.6.2"?>
<!DOCTYPE KEYS SYSTEM "C:\TSM\System\DTD\TSMLte.dtd">


I'm getting the <?xml> tag by default now, but how can I add the other header elements?



DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("TOP");
doc.appendChild(rootElement);

DOMSource domSource = new DOMSource(doc);

No comments:

Post a Comment