Hello - have been stuck on this for days now- How can I loop every node in an XML document and change the text value of the node.
For example go from this:
<root>
<node1>some text</node1>
<node2>
<node3>some more text</node3>
</node2>
</root>
to something like:
<root>
<node1>updated text</node1>
<node2>
<node3>updated text</node3>
</node2>
</root>
The code I have that doesn't work is:
NSArray *nodes = [xmlDoc nodesForXPath:@"//*"];
for (NSXMLElement *node in nodes) {
//In time a function call will go here to change the text:
NSString *newVal = @"updated text";
[node setStringValue:newVal];
}
Although it seems to loop ok when i check the contents of XMLDoc it then has this in it:
<root>
updated text
</root>
Please help if you can I have tried repeated google searches and am pulling my (already thinning) hair out - surely this should be fairly simple?!
Matt.