简体   繁体   中英

Retrieving data from XML file into GridView

i have retrieved Data from xml file and displayed it in gridview using C#, but i want to show all data including the inner tags here is my C# code:

XmlDataDocument xmlDatadoc = new XmlDataDocument();
xmlDatadoc.DataSet.ReadXml("D:\\ab.xml");

DataSet ds = new DataSet("Books DataSet");
ds = xmlDatadoc.DataSet;
dataGridView1.DataSource = ds.DefaultViewManager;
dataGridView1.DataMember = "CP";

and this is the xml:

<?xml version="1.0" encoding="utf-8" ?>    
<Permission>
    <CP name="Student">
        <tab name="studentinfo"></tab>
        <tab name="notes">
        <groupbox name="ss">
            <field type="textArea" x="xxx" />
        </groupbox>
        </tab>
    </CP>
    <CP name="Teacher"></CP>
    <CP name="doctor"></CP>
</Permission>

i want after it shows data of <CP> it shows data of <tab> then <groupbox> etc if any confusion please let me know

I think your problem is not between the XML and gridview but between the XML and dataset.
see how-do-i-use-xml-as-a-datasource-for-a-datagridview-in-a-winforms-project and import-xml-into-dataset for a discussion of how to parse XML into a dataset.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM