Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Iterator; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static NodeList ChangeNode(NodeList listNode, ArrayList<String> arrStrCompare, String strNewValue) { ArrayList<String> arrTempList = arrStrCompare; Iterator<String> iterator = arrTempList.iterator(); while (iterator.hasNext()) { String strCompare = (String) iterator.next(); iterator.remove(); for (int i = 0; i < listNode.getLength(); i++) { Node node = listNode.item(i); if (strCompare.equals(node.getNodeName())) { if (iterator.hasNext()) { node = ChangeNode(node.getChildNodes(), arrTempList, strNewValue).item(0); break; } node.setTextContent(strNewValue); break; } } } return listNode; } }