I'm building an app with Appcelerator Studio that can parse an XML file and can also change some elements of this document.
Now in my XML file, I have this:
<partecipant>
<name>Pippo</name>
</partecipant>
Now I can read the value of Node "name" (Pippo) with this code:
var partecipant = document.getElementsByTagName('participant');
var location = partecipant.item(0).getElementsByTagName('name').item(0).text;
But I'm not able to change this value of this node. I'm trying to use this code (but not works):
var nameNode = nameNodes.item(0); //(I get the element NAME from XML file)
nameNode.text ='PLUTO';
nameNode.textContent = 'PLUTO';
nameNode.setNodeValue('PLUTO');
With this code I can't change the value of the tag NAME.
I solved this by changing the nodeValue of the firstChild of the node and not the node itself.
Change your code to:
nodeName.getFirstChild().nodeValue = 'PLUTO';
It worked for me.