>>792
サンプル
static void appendAndRename() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new FileInputStream("あ.xml"));
Element root = doc.getDocumentElement();
NodeList list = root.getElementsByTagName("c");
Node node = list.item(0);
Node child1 = doc.createElement("k");
Node child2 = doc.createElement("g");
Node child3 = doc.createTextNode("あああ");
child2.appendChild(child3);
child1.appendChild(child2);
node.appendChild(child1);
list = root.getElementsByTagName("g");
node = list.item(0);
node = doc.renameNode(node, node.getNamespaceURI(), "年齢");
FileOutputStream out = new FileOutputStream("newあ.xml");
DOMSource src = new DOMSource(root);
StreamResult dst = new StreamResult(out);
Transformer tfm = TransformerFactory.newInstance().newTransformer();
tfm.transform(src, dst);
out.close();
}