Update the node instance code to xml, and the xml node instance code.
Update node instance code to xml
/* System. out. println ("2323"); DocumentBuilderFactory factory = DocumentBuilderFactory. newInstance (); DocumentBuilder docbuilder = factory. newDocumentBuilder (); Document parse = docbuilder. parse (new File ("src/ProdQuery. xml "); // Element createElement2 = parse. createElement (""); Element createElement = parse. createElement ("products"); Node item2 = parse. getChildNodes (). item (parse. getChildNodes (). getLength ()-1); for (String item: map. keySet () {// Add to productsSystem cyclically. out. println ("tianjia1"); Element clivity = parse. createElement ("product"); Attr createAttribute = parse. createAttribute ("name"); createAttribute. setNodeValue (item); Attr createAttribute2 = parse. createAttribute ("value"); createAttribute2.setNodeValue (map. get (item); climit. setAttributeNode (createAttribute); cli.pdf. setAttributeNode (createAttribute2); createElement. appendChild (client);} // Add products to the root directory item2.appendChild (createElement); // create a TransformerFactory object TransformerFactory tFactory = TransformerFactory. newInstance (); // get an operation object Transformer transformer = tFactory. newTransformer (); // sets the transformer encoding. setOutputProperty (OutputKeys. ENCODING, "UTF-8"); // DOMSource source = new DOMSource (parse); System. out. println ("change File"); StreamResult result = new StreamResult (new File ("src/ProdQuery. xml "); // Let the xml file wrap transformer. setOutputProperty (OutputKeys. INDENT, "yes"); transformer. setOutputProperty ("{ http://xml.apache.org/xslt } Indent-amount "," 4 "); transformer. transform (source, result );*/
The above example code for updating nodes in xml is all the content that I have shared with you. I hope you can give me a reference and support the help house.