<root>
<program name="SomeProgramName">
<params>
<param name='name'>test</param>
<param name='name2'>test2</param>
</params>
</program>
</root>
I have the above xml doc. I need to change the value of test to a new value
I read in the xml doc as
String xmlfile = "path\\to\\file.xml"
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(xmlfile);
//get the params element
Node params = doc.getElementsByTagName("params").item(0);
//get a list of nodes in the params element
NodeList param = params.getChildNodes();
This is where I am stuck. I can't find a method to set the value of one of the param elements by the "name"
I'm using java 1.7