Connecting Tech Pros Worldwide Forums | Help | Site Map

Reading in XML file, changing elements and saving back to the file

Gerald Maher
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi

Reading in XML file, changing elements and saving back to the file,
how can i do that, I want to be able to read an XML file and read out
Elements. for example

<name>Tom</tom>

When I read from a file i want to save the XML document in memory of
the computer and when i am finished flush it back to the file, that
means i want to be able to access the element in memory of the
computer and when i change it will write it back with new changes.

What is the Best way to do that ?
I have tried it wiht xmlReader and xmlWrite, this is not saved in the
computer.

Martin Honnen
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Reading in XML file, changing elements and saving back to the file




Gerald Maher wrote:[color=blue]
> Reading in XML file, changing elements and saving back to the file,
> how can i do that, I want to be able to read an XML file and read out
> Elements. for example
>
> <name>Tom</tom>
>
> When I read from a file i want to save the XML document in memory of
> the computer and when i am finished flush it back to the file, that
> means i want to be able to access the element in memory of the
> computer and when i change it will write it back with new changes.[/color]

Sounds as if you are looking for System.Xml.XmlDocument

--

Martin Honnen
http://JavaScript.FAQTs.com/

Kalpesh Shah
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Reading in XML file, changing elements and saving back to the file


XMLDocument xdoc = new XMLDocument(@"c:\myfile.xml");

// do the changes to the xdoc (in-memory dom)

xdoc.save(@"c:\myfile.xml");

I think this should work - havent tried it though ;-)

HTH
Kalpesh

Closed Thread