J. POLITECHNIKA RZESZOWSKA - Wydział Elektrotechniki I Informatyki
I import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.transform.dom.*; import javax.xml.transform.*; import j avax.xml.trans form.st ream.*; import j ava.io.*;
public class CreateNewDocumentDOM {
public static void main(String[] args) { try (
DocumentBuilderFactory dbfactory =
DocumentBuilderFactory.newlnstance(); DocumentBuilder builder = dbfactory.newDocumentBuilder(); Document document = builder.newDoaument();
Element rootElement = document.createElement("addressbook"); rootElement.setAttribute("Att_Name","Att_Value”); document.appendChild(rootElement);
Element childElementl = document.createElement("person"); childElementl.appendChild(document.createTextNode("JP”)); rootElement.a^jendChild(childElementl);
U