XML Format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tushar Mhaskar
    New Member
    • Dec 2011
    • 3

    XML Format

    Hi ,
    I have One XML File In That There Have One Parent Node Having Similar Name Of Multiple ChildNode
    Eg:
    Code:
     <entry>
      <string>isprivacyprotectionallowed</string> 
      <string>true</string> 
     </entry>
     <entry>
      <string>registrantcontactgroup</string> 
      <string>Contact</string> 
     </entry>
    I wanted To Bind XML File In Gridview
    Please help me out. How can I Do this?

    Thanks And Regards ,
    Tushar
    Last edited by Frinavale; Dec 7 '11, 02:05 PM. Reason: Added code tags and fixed the spelling of the word "Please".
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Use the XMLReader Class to populate a DataTable that you can use as the data source for your GridView.

    For example:
    (C#)
    Code:
    System.Data.DataTable dt = new System.Data.DataTable("Entries");
    System.Xml.XmlReader xr = System.Xml.XmlReader.Create("PathToXml/Entries.xml");
    
    dt.ReadXmlSchema(xr);
    dt.ReadXml(xr);
    
    xr.close();
    
    myGridView.DataSource = dt;
    myGridView.DataBind();
    (VB.NET)
    Code:
    Dim dt As New System.Data.DataTable("Entries")
    Dim xr As System.Xml.XmlReader = System.Xml.XmlReader.Create("PathToXml/Entries.xml")
    
    dt.ReadXmlSchema(xr)
    dt.ReadXml(xr)
    
    xr.close()
    
    myGridView.DataSource = dt
    myGridView.DataBind()
    -Frinny

    Comment

    • Tushar Mhaskar
      New Member
      • Dec 2011
      • 3

      #3
      I did that but because of String element it is Not working.

      I will send whole XML here. Please check and give a solution.
      Last edited by Frinavale; Dec 8 '11, 02:04 PM. Reason: Fixed the spelling of the words "Please" and "Because"

      Comment

      • Tushar Mhaskar
        New Member
        • Dec 2011
        • 3

        #4
        XML Format

        Hi, please check attachment XMLForDomain.txt
        Last edited by Frinavale; Dec 8 '11, 02:05 PM. Reason: Fixed the spelling of the word "please"

        Comment

        Working...