Search in XML and show results in GridView

Total Post:101

Points:709
C#  XML  Gridview 
C#
 1342  View(s)
Ratings:
Rate this:

I have an XML data of Employees, I want to parse this data and show it in Gridview using C# in ASP.NET. 

Based on search parameters like Employee ID or Company ID or Department ID, I should be able to filter the data and update the GridView. 

Checked few links in internet, but nothing matches this particular format.. Is it possible to achieve.. (Any links to) code will be helpful. 

  <?xml version="1.0" encoding="utf-8"?>
      <Employees>
        <Employee>
          <Id> TG18-2002</Id>
          <Name> AAPM^Test^Patterns</Name>
          <Sex> O </Sex>
          <Company>
            <Id> 2.16</Id>           
            <Department>
              <Id> 2.16.124</Id>
              <Project>
                <Id> 2.16.124.113543</Id>
              </Project>
            </Department>
          </Company>
        </Employee>
        <Employee>
          <ID> TG18-2003</ID>
          <Name> AAPM^Test^Patt</Name>
          <Sex> O </Sex>
          <Company>
            <ID> 2.16</ID>           
            <Department>
              <ID> 2.16.124</ID>
              <Project>
                <ID> 2.16.124.113543</ID>
              </Project>
            </Department>
          </Company>
        </Employee>
        <Employee>
      </Employees>

  1. Post:378

    Points:2694
    Re: Search in XML and show results in GridView

    HI Pravesh, 


    try this:

    DataSet xmlData = new DataSet();

    xmlData.ReadXml(YourXMLPath);

    GridviewControl1.DataSource = xmlData.Tables[0];

Answer