You need to sign in to do that
Don't have an account?
How To Replace A Text In a DOM.XMLNode
Hi,
I have a requirement to check if a XML paramter Node contians certain text and if so to replace it.
With the following code for example. I would need to replace the content I get via
arrayOfActionTypeNode.getText()
for(String parameterName : this.paramterMap.keySet()) {
arrayOfFieldTypeNode = this.paramterMap.get(parameterName).toXML(arrayOfFieldTypeNode);
if (parameterName.contains('AccountID')) {
System.debug('AccountIDVal=' + this.paramterMap.get(parameterName));
System.debug('arrayOfFieldTypeNode=' + arrayOfFieldTypeNode);
System.debug('nameVal=' + arrayOfFieldTypeNode.getName());
System.debug('textVal=' + arrayOfFieldTypeNode.getText());
}
}
I tried it with
arrayOfActionTypeNode.getText().put('test') but a similar function is not available.
If I want to update the text in the parameter do I need to delete the attribute or child first via removeAttribute/removeChild and create a new one, or is there a simpler way of doing this?
Thanks in advance for your help.
^bump^
Any help on this?
if(node.getNodeType()+''=='TEXT' ){
dom.XmlNode par = node.getParent();
par.removeChild(node);
par.addTextNode('Your Replacement text');
}