One, the code is as follows
Package Com.wujianbo.five;import Java.io.file;import Java.security.cert.trustanchor;import Javax.xml.parsers.documentbuilder;import Javax.xml.parsers.documentbuilderfactory;import Javax.xml.transform.transformer;import Javax.xml.transform.transformerfactory;import Javax.xml.transform.dom.domsource;import Javax.xml.transform.stream.streamresult;import org.w3c.dom.Document; Import Org.w3c.dom.element;public class Demo09 {public static void main (string[] args) throws Exception {//TODO Auto-gene Rated method stubDemo09 demo09= new Demo09 ();d emo09.createxmlbydom (); private void Createxmlbydom () throws Exception {//TODO auto-generated method stubdocumentbuilderfactory dbf= Documentbui Lderfactory.newinstance ();d bf.setignoringelementcontentwhitespace (true); String xmlname= system.getproperty ("User.dir") + "\\data\\NewStudents.xml";//system.out.println (XMLName);D Ocumentbuilder db= Dbf.newdocumentbuilder ()//system.out.println (db);D ocument doc= db.parse (xmlName);//Element Root = Doc.getdocumentelement ();//element son= doc.createelement ("Son")//son.setattribute ("id", "001");//element name= doc.createelement (" Name ");//name.settextcontent (" Son ");//son.appendchild (name);//element age= doc.createelement (" age ");// Age.settextcontent ("ten");//son.appendchild (age);////root.appendchild (son);////transformerfactory factory= Transformerfactory.newinstance ();//transformer former= Factory.newtransformer ();//former.transform (New DOMSource ( DOC), New Streamresult (New File (XMLName)));}}
"Automation _ Continuous Integration" ___java___xml__dom Tim