Modify XML document using C#

I am using C#  and I would like to programmatically modify an XML file and save it back to my C: drive.

I have 1000 main elements and within each of those there a child node element values that need to be altered.

Is there a really quick and effective way of doing this?

Thanks for your help.

Who is Participating?
lucky_jamesConnect With a Mentor Commented:
one more, using xmldocument, for modifying and saving the xmls:
xml operations can be seen at:

Hope it helps.
vjc2003Connect With a Mentor Commented:
Follow these steps:
1. Load the XML Doc
2. Select the nodes you want to modify
3. Loop through the selected nodes and modify the element values
And you are done.. :)

I'm attaching Dummy code..
Dim xDom As New XmlDocument
Dim xNodes as XmlNodeList
xNodes = xDom.SelectNodes(NAME_OF_MAIN_ELEMENT)  
For Each xNode as XmlNode in xNodes
'//get OR set element value:
strElemenValue = xNode.Attributes.GetNamedItem(NAME_OF_ELEMENT).InnerText

Open in new window

IbsAuthor Commented:
Thanks! Both very useful.
All Courses

From novice to tech pro — start learning today.