Modify XML document using C#

Hi,
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.



 
IbsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lucky_jamesCommented:
xml operations can be seen at:
http://www.codersource.net/csharp_xml_file_operations.html

Hope it helps.
0
lucky_jamesCommented:
one more, using xmldocument, for modifying and saving the xmls:
http://support.microsoft.com/kb/301233
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vjc2003Commented:
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
xDom.Load(strFileName)
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
Next

Open in new window

0
IbsAuthor Commented:
Thanks! Both very useful.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.