Select Nodes from XML File

  • 9 years ago
    Hai all i am doing a VB.NET windows application . In that i am using an xml file having the following format<?xml version="1.0" encoding="utf-8"?><CardDetRoot>           <CardDet>                           <CardCode>CC1</CardCode>                           <OrgCode>O1</OrgCode>                           <CardName>O1CC1</CardName>                            <CardType>SAM</CardType>                            <MemSize>4K</MemSize>           </CardDet>           <CardDet>                            <CardCode>CC2</CardCode>                           <OrgCode>O2</OrgCode>                             <CardName>O2CC2</CardName>                             <Card Type>USER</CardType>                          <MemSize>4K</MemSize>                </CardDet>               <CardDet>                            <CardCode>CC3</CardCode>                            <OrgCode>O2</OrgCode>                            <CardName>O2CC3</CardName>                           <CardType>USER</CardType>                             <MemSize>4K</MemSize>              </CardDet>              <CardDet>                      <CardCode>CC4</CardCode>                       <OrgCode>O1</OrgCode>                      <CardName>O1CC4</CardName>                      <CardType>USER</CardType>                      <MemSize>8K</MemSize>             </CardDet></CardDetRoot> Here what i want to do is i want to select distinct OrgCode ie. O1  and O2. Then for each OrgCode i want to select CardCode, CardName, CardType and MemSize.Then Bind each OrgCode Details to different DataGrid.That is for O1 there are 2 records  Record 1 : CardCode = CC1, CardName = O1CC1, CardType = SAM , MemSize = 4K  Record 2 : CardCode = CC4, CardName = O1CC4, CardType = USER, MemSize = 8KI want to show there 2 records in one datagrid with datagrid heading as O1. Similarly for O2 there are 2 records Record 1 : CardCode = CC2, CardName = O2CC2, CardType = USER , MemSize = 4K Record 2 : CardCode = CC3, CardName = O2CC3, CardType = USER, MemSize = 4KI want to show there 2 records in one datagrid with datagrid heading as O2. How i can do this .. Anybody knows ? Any help appreciated . Thanks in Advance 

     

  • 9 years ago

    Tongue Tied You put whole project on our backs. Impossible. You just parse XML into standart datasource / datatable object. And then you bind it somehow to grids. Here is lot of parsing stuff http://www.vbdotnetheaven.com/Articles/ArticleListing.aspx?SectionID=2&SubSectionID=124

    Give a try. Have a luck!

  • 9 years ago
    This is not the whole project.... not even one-fourth of the project.. i asked this question as i am new to XML ...and ve no prior experience in XML
  • 9 years ago

    Ok I tried to make a first step XML to DataSet to GridView demo :) It is easier than I suppose. Anyway your xml file is incorrect. Look in demo bin directory at x.xml. All what it does is "ds.ReadXml("x.xml", XmlReadMode.Auto)" in real. So your is to finish its data-relation works.

    enjoy

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“XML is like violence - if it's not working for you, you're not using enough of it.”