C# read/write xml

Nov 6 2007 5:34 AM

I have the following XML file, which I intend to use to read and save to it.

------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<Base>
  <John Count="123" />
  <Dave Count="698" />
</Base
------------------------------------------------------------------

The nodes are self closing and each one has 1 attribute.

Sometimes I just want to read this attribute and show on the page, other times I want to read it add +1 and save it.

I just want to say, read node of name xxxx and give me its attribute value.

What would be the best and simplest way to do this in C#?

I have been playing around with XmlTextReader/Writer and cant get this to work, also tried many other approaches, all failed.

Thanks.


Answers (2)