Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple tables in dataset from XML

Status
Not open for further replies.

GabeC

Programmer
Apr 17, 2001
245
US
I have searched the web and this forum and found many articles but I am not understanding how to get child data in an XML structure.

I've read to use the DataViewManager but I'm not understanding it.

Here is an example of the XML document.


<?xml version="1.0" encoding="utf-8" ?>
<myXML>
<Item name="xyz">
<Benefits>
<Benefit>Looks Good</Benefit>
<Benefit>Priced Right</Benefit>
<Benefit>Works Well</Benefit>
</Benefits>
</Item>
<Item name="abc">
<Benefits>
<Benefit>Looks Good</Benefit>
<Benefit>Light Weight</Benefit>
<Benefit>Cutting Edge</Benefit>
</Benefits>
</Item>
</myXML>


From the example above, how do I find all the items that has a benefit of Cutting Edge?

Code:
dim g_XMLDocument as string = "c:\myDoc.xml"
Dim m_DS As DataSet = New DataSet
m_DS.ReadXml(g_XMLDocument)
What do I do next? My eventual goal is to bind the list of Items to a list box or data grid.



Thanks,

Gabe
 
The dataset will have multiple tables in it to match the XML file. I would recommend saving the data to XML with a schema, it will make it much easier to see the parent/child tables and their relations.

You should be able to use DataSet.Table(index) to access the different tables.

-Rick



VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks ThatRickGuy.

I am able to access each table in the dataset and I can get a list of the relationships between the tables but I'm not sure what code to use to get the specific data I want. I have tried many examples but none of them seem to work for me.

From the code above, now that I have the DataSet loaded from the XML document, I'm at a loss on how to select all the Items that have a Benefit that equals Cutting Edge.



Thanks,

Gabe
 
Have you looked up DataView?

Rhys
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense Edsgar Dijkstra
If life were fair, Dan Quayle would be making a living asking 'Do you want fries with that?' John Cleese
 
Yeah,

I've looked up the DataView and the DataViewManager. I've tried dozens of examples but I'm just not getting it.

I don't usually ask for specific code because I learn more if I figure it out myself but this has me stumped.

I would appreciate it if someone could Show Me the Code.

thread796-1044606 tries to explain this but it didn't work for me.



Thanks,

Gabe
 
In this thread thread796-1061219 there is a program I made to make a clickable US map, but I put in a block of code that reads information about the map from an XML file. Download the code and give it a run through.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top