Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Pull nested xml values into Datagrid

Pull nested xml values into Datagrid

Scheduled Pinned Locked Moved ASP.NET
htmlxmlquestionannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ErikKoz
    wrote on last edited by
    #1

    Im looking to display xml values via a datagrid. And so far Ive had luck with everything, except nested values.

    <?xml version="1.0" encoding="UTF-8"?>
    <Collection>
    <Content>
    <ID>16938</ID>
    <Type>Content</Type>
    <Title>Smartform2</Title>
    <QuickLink>/it.aspx?id=16938</QuickLink>
    <Teaser>
    <p>SmartForm1Smartform2Smartform3Smartform4</p>
    </Teaser>
    <Html>
    <root>
    <Field1>
    <Field2>
    <Test1>SmartForm1</Test1>
    <Test2>Smartform2</Test2>
    </Field2>
    <Field2>
    <Test1>Smartform3</Test1>
    <Test2>Smartform4</Test2>
    </Field2>
    </Field1>
    </root>
    </Html>
    <StartDate>1/1/0001 12:00:00 AM</StartDate>
    <DateModified>5/28/2009 3:02:59 PM</DateModified>
    <DateCreated>5/28/2009 3:02:49 PM</DateCreated>
    <EndDate>12/31/9999 11:59:59 PM</EndDate>
    <LastEditorFname>Erik</LastEditorFname>
    <LastEditorLname>Kozlowski</LastEditorLname>
    <Hyperlink>
    <a href="/it.aspx?id=16938">Smartform2</a>
    </Hyperlink>
    <DisplayStartDate/>
    <FolderID>2594</FolderID>
    <ContentStatus>A</ContentStatus>
    <Language>1033</Language>
    <DisplayDateModified>5/28/2009</DisplayDateModified>
    <DisplayDateCreated>5/28/2009</DisplayDateCreated>
    <DisplayEndDate/>
    <EndDateAction>Archive_Expire</EndDateAction>
    <Comment/>
    <Image>/WorkArea/images/application/spacer.gif</Image>
    <ImageThumbnail>/WorkArea/images/application/thumb_spacer.png</ImageThumbnail>
    <FilePath>/it.aspx?id=16938</FilePath>
    </Content>
    <Content>
    <ID>16936</ID>
    <Type>Content</Type>
    <Title>Test smartform 1</Title>
    <QuickLink>/it.aspx?id=16936</QuickLink>
    <Teaser>
    <p>Smart1Smart2Smart3Smart4</p>
    </Teaser>
    <Html>
    <root>
    <Field1>
    <Field2>
    <Test1>Smart1</Test1>
    <Test2>Smart2</Test2>
    </Field2>
    <Field2>
    <Test1>Smart3</Test1>
    <Test2>Smart4</Test2>
    </Field2>
    </Field1>
    </root>
    &

    B A 2 Replies Last reply
    0
    • E ErikKoz

      Im looking to display xml values via a datagrid. And so far Ive had luck with everything, except nested values.

      <?xml version="1.0" encoding="UTF-8"?>
      <Collection>
      <Content>
      <ID>16938</ID>
      <Type>Content</Type>
      <Title>Smartform2</Title>
      <QuickLink>/it.aspx?id=16938</QuickLink>
      <Teaser>
      <p>SmartForm1Smartform2Smartform3Smartform4</p>
      </Teaser>
      <Html>
      <root>
      <Field1>
      <Field2>
      <Test1>SmartForm1</Test1>
      <Test2>Smartform2</Test2>
      </Field2>
      <Field2>
      <Test1>Smartform3</Test1>
      <Test2>Smartform4</Test2>
      </Field2>
      </Field1>
      </root>
      </Html>
      <StartDate>1/1/0001 12:00:00 AM</StartDate>
      <DateModified>5/28/2009 3:02:59 PM</DateModified>
      <DateCreated>5/28/2009 3:02:49 PM</DateCreated>
      <EndDate>12/31/9999 11:59:59 PM</EndDate>
      <LastEditorFname>Erik</LastEditorFname>
      <LastEditorLname>Kozlowski</LastEditorLname>
      <Hyperlink>
      <a href="/it.aspx?id=16938">Smartform2</a>
      </Hyperlink>
      <DisplayStartDate/>
      <FolderID>2594</FolderID>
      <ContentStatus>A</ContentStatus>
      <Language>1033</Language>
      <DisplayDateModified>5/28/2009</DisplayDateModified>
      <DisplayDateCreated>5/28/2009</DisplayDateCreated>
      <DisplayEndDate/>
      <EndDateAction>Archive_Expire</EndDateAction>
      <Comment/>
      <Image>/WorkArea/images/application/spacer.gif</Image>
      <ImageThumbnail>/WorkArea/images/application/thumb_spacer.png</ImageThumbnail>
      <FilePath>/it.aspx?id=16938</FilePath>
      </Content>
      <Content>
      <ID>16936</ID>
      <Type>Content</Type>
      <Title>Test smartform 1</Title>
      <QuickLink>/it.aspx?id=16936</QuickLink>
      <Teaser>
      <p>Smart1Smart2Smart3Smart4</p>
      </Teaser>
      <Html>
      <root>
      <Field1>
      <Field2>
      <Test1>Smart1</Test1>
      <Test2>Smart2</Test2>
      </Field2>
      <Field2>
      <Test1>Smart3</Test1>
      <Test2>Smart4</Test2>
      </Field2>
      </Field1>
      </root>
      &

      B Offline
      B Offline
      Bassam Saoud
      wrote on last edited by
      #2

      I am assuming you are loading the xml to a dataset before binding the grid. Since you have nested xml, they will be loaded as different datatables I think. If this is the case, you can use the merge function to marge the datatables in your dataset and get it to display in your grid. This will be my first try.. There are many other way to do this. It all depends on the complixity of your xml structure

      1 Reply Last reply
      0
      • E ErikKoz

        Im looking to display xml values via a datagrid. And so far Ive had luck with everything, except nested values.

        <?xml version="1.0" encoding="UTF-8"?>
        <Collection>
        <Content>
        <ID>16938</ID>
        <Type>Content</Type>
        <Title>Smartform2</Title>
        <QuickLink>/it.aspx?id=16938</QuickLink>
        <Teaser>
        <p>SmartForm1Smartform2Smartform3Smartform4</p>
        </Teaser>
        <Html>
        <root>
        <Field1>
        <Field2>
        <Test1>SmartForm1</Test1>
        <Test2>Smartform2</Test2>
        </Field2>
        <Field2>
        <Test1>Smartform3</Test1>
        <Test2>Smartform4</Test2>
        </Field2>
        </Field1>
        </root>
        </Html>
        <StartDate>1/1/0001 12:00:00 AM</StartDate>
        <DateModified>5/28/2009 3:02:59 PM</DateModified>
        <DateCreated>5/28/2009 3:02:49 PM</DateCreated>
        <EndDate>12/31/9999 11:59:59 PM</EndDate>
        <LastEditorFname>Erik</LastEditorFname>
        <LastEditorLname>Kozlowski</LastEditorLname>
        <Hyperlink>
        <a href="/it.aspx?id=16938">Smartform2</a>
        </Hyperlink>
        <DisplayStartDate/>
        <FolderID>2594</FolderID>
        <ContentStatus>A</ContentStatus>
        <Language>1033</Language>
        <DisplayDateModified>5/28/2009</DisplayDateModified>
        <DisplayDateCreated>5/28/2009</DisplayDateCreated>
        <DisplayEndDate/>
        <EndDateAction>Archive_Expire</EndDateAction>
        <Comment/>
        <Image>/WorkArea/images/application/spacer.gif</Image>
        <ImageThumbnail>/WorkArea/images/application/thumb_spacer.png</ImageThumbnail>
        <FilePath>/it.aspx?id=16938</FilePath>
        </Content>
        <Content>
        <ID>16936</ID>
        <Type>Content</Type>
        <Title>Test smartform 1</Title>
        <QuickLink>/it.aspx?id=16936</QuickLink>
        <Teaser>
        <p>Smart1Smart2Smart3Smart4</p>
        </Teaser>
        <Html>
        <root>
        <Field1>
        <Field2>
        <Test1>Smart1</Test1>
        <Test2>Smart2</Test2>
        </Field2>
        <Field2>
        <Test1>Smart3</Test1>
        <Test2>Smart4</Test2>
        </Field2>
        </Field1>
        </root>
        &

        A Offline
        A Offline
        adatapost
        wrote on last edited by
        #3

        After loading an XML file into DataSet; DataSet creates number of DataTable instances so you have to decide which datatable instance you want to use. For Example, DataSet ds=new DataSet(); ds.ReadXml(....); // List of DataTables for(int i=0;iA DATAPOST COMPUTER CENTRE (K.V Prajapati)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups