JR

JR

  • NA
  • 16
  • 32.8k

Read XML file with multiple nodes and display in datagridview

Feb 6 2011 10:57 AM
Hello,

I have an XML file with the following layout:

    <name>
        <item1>Test</item1>
        <item2>0</item2>
        <info>
            <info1>service</info1>
            <info2>service</info2>
        </info>
    </name>

I use this code to read the XML file:

  string filePath = "C:\\Users\\test\\Desktop\\test.xml";

//XmlTextReader r = new XmlTextReader(filePath);

dsXML.ReadXml(filePath, XmlReadMode.Auto);
dgvXML.AutoGenerateColumns = true;
dgvXML.DataSource = dsXML;
dgvXML.DataMember = "name";

However, I only get the following columns in the datagridview:

item1
item2

but I would like to see:

item1
item2
info1
info2

What am I doing wrong?

Thanks in advance.


Answers (3)