I want to remove some elements from an XML file using groovy, however this does not seem to work.
Any ideas how to solve this?
def DeploymentDescriptors = new XmlSlurper().parse("pathToMyXMLFile")
DeploymentDescriptors.NameValuePairs.NameValuePair.each {
if(it.name == 'B')
it.replaceNode{}
}
XML File
<DeploymentDescriptors>
<NameValuePairs>
<NameValuePair>
<name>A</name>
<value>Value A</value>
</NameValuePair>
<NameValuePair>
<name>B</name>
<value>Value B</value>
</NameValuePair>
<NameValuePair>
<name>C</name>
<value>Value C</value>
</NameValuePair>
</NameValuePairs>
</DeploymentDescriptors>