I have a node in an xml document that has the following general structure:
String xml = "
<root>
<firstNode class="first">SomeText<childNode class="child">SomeMoreText</childNode></firstNode>
</root>"
I want to modify the text of the firstNode node. So I want to change the value of "SomeText" to something else, like "NewText". So the above xml would look like this:
<root>
<firstNode class="first">NewText<childNode class="child">SomeMoreText</childNode></firstNode>
</root>"
I can get the firstNode node using the XmlParser class:
def firstNode = new groovy.xml.XmlParser().parseText(xml).root[0]
From the Node doc I am able to get the "SomeText" value using firstNode.localText()[0] but I can't figure out how to set that text. Somehow I was thinking of doing firstNode.setValue() but I don't know what to pass in that function.
Thanks for any ideas!