Write XML node value

Cassio

Well-known member
Joined
Nov 30, 2002
Messages
276
Location
Rio de Janeiro
Hi! How can I change the inner text of a specific node? I tried to use XMLTextWritter but it erases the content of the file before writting.

Thanks!
 
I assume youre talking about changing a node in an XML document on disk? The only way I know of is to load the XML into an XmlDocument, locate the right node with XPath (probably selectSingleNode) and then change its text (or is it nodeText) property. You probably dont want innerText in case there are nested nodes - the innerText will contain all of the inner text, not just for your node. Finally, youll have to save the XML back to file.

-ner
 
Thanks, Nerseus. I got a book that describes this method but it didnt mention that I had to use th save command. It took me the whole day to find it out. :p
 
Back
Top