Home > DeveloperSection > Forums > Search in XML and show results in GridView
Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    November-17-2014 11:40 PM

 C# C#  XML  Gridview 
Ratings:


 1 Reply(s)
 708  View(s)
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>



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    November-17-2014 11:47 PM

HI Pravesh, 

try this:

DataSet xmlData = new DataSet();

xmlData.ReadXml(YourXMLPath);

GridviewControl1.DataSource = xmlData.Tables[0];


Don't want to miss updates? Please click the below button!

Follow MindStick