This content has been marked as final. Show 3 replies
There are almost certainly tutorials on this site that'll give better and more complete examples than I could throw together quickly.
But basically it comes down to:
1) create the DocumentBuilderFactory
2) create the DocumentBuilder
3) parse, resulting in a Document
4) find the node you're looking for (options vary depending on the version of the JDK, apparently)
5) use methods on the Document object to create the new node
6) add the new node to the node you found in (4)
7) write it all back out again. IIRC Document's toString handles formatting the XML just fine, so all you have to do is System.out.println(the Document) for this.