Sumitra Paul

Sumitra Paul

  • NA
  • 51
  • 33.6k

Reading XmlDocument element values in c#

Mar 31 2014 1:29 AM

Hi,

I have a xmlDocument. When debug i can see that it has values DocumentElement and inside documentElement I can see innerXml which actually contains the value that I have saved.

Now, I dont know how to iterate through it to get all the values.

searhed google but did not find something clearly.

I am able to read till inner xml. Please see the code below.

        XmlDocument settings = // read
        XmlElement root = Settings.DocumentElement;
        XmlNodeList elements = root.ChildNodes;

        for(int i = 0; i < elements.Count; i++)
        {
                val innerXml = elements[i].innerXml;
        }

can someone help me to read the inner xml value. I am using .NET framework 4.0.
Please let me know if there is any better way to do this.

Thanks

Answers (2)