Quantcast
Viewing all articles
Browse latest Browse all 8068

Edit content of XML

Hi,

I want to edit the content of my XML (see below). I'm trying to change the value 50 with 70 in my file.

Here is my code, I don't know what I'm doing wrong please help

var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'AppSettings.xml');
var xmlText = file.read().text;
var xmlDoc = Ti.XML.parseString(xmlText);
var doc = xmlDoc.documentElement;
var sNodes = doc.getElementsByTagName("MaxStry");
 
sNodes.item(0).textContent = 70;
 
Ti.XML.serializeToString(sNodes.item(0));
file.write(xmlDoc);
and here is the content of my XML
<?xml version="1.0" encoding="UTF-8"?>
 
<Resources>
    <MaxStry>50</MaxStry>
</Resources>

Viewing all articles
Browse latest Browse all 8068

Trending Articles