Adding an Element with DOM
import org.w3c.dom.Document; import org.apache.xerces.dom.DOMImplementation; import org.w3c.dom.Element; public class MainClass { public static void main(String args[]) { Document dom = DOMImplementation.createDocument(null, null, null); Element root = dom.createElement("games"); Element child1 = dom.createElement("game"); root.appendChild(child1); dom.appendChild(root); } }
1. | Walking a Document with DOM | ||
2. | Adding an Attribute with DOM | ||
3. | Outputting a DOM with XMLSerializer | ||
4. | Parsing XML with SAX | ||
5. | A simple example to show how to use the DOM API |