XML help please - never worked with this structure before
-
Hello, I've been given a sample XML file in a structure that I haven't handled in VB.NET before and would appreciate some guidance. The structure is as follows:
<Interface CompanyCode="COMP01" CreatedOn="2007-05-27T10:20:00" CreatedBy="PRODUCT" CreatorKey="PROD" SequenceNo="1" CreatorReference="NEWPRODUCT"> <Product ProductCode="P1"> <Description>Product 1 Description</Description> </Product> <Product ProductCode="P2"> <Description>Product 2 Description</Description> <Value EffectiveDate="2006-04-01"> <Price>5.50</Price> <Currency>GB</Currency> </Value> </Product> <Product ProductCode="P3"> <Description>Product 3 Description</Description> </Product> </Interface>
When I read the xml file in with ...Dim ds As DataSet = New DataSet("dataset") ds.ReadXml("prod2.xml") With DataGridView1 .DataSource = ds .DataMember = ds.Tables(2).TableName End With
... I can see that I've got 3 x tables ... "Interface", "Product", "Value". What I'm wondering is how do I get the "Value" table linked to "Product"? I was expecting (rightly or wrongly) to see some inherited values from product displayed in my DataGridView. Looking at the structure of the XML file, it seems to imply that there should be some inheritance??? -
Hello, I've been given a sample XML file in a structure that I haven't handled in VB.NET before and would appreciate some guidance. The structure is as follows:
<Interface CompanyCode="COMP01" CreatedOn="2007-05-27T10:20:00" CreatedBy="PRODUCT" CreatorKey="PROD" SequenceNo="1" CreatorReference="NEWPRODUCT"> <Product ProductCode="P1"> <Description>Product 1 Description</Description> </Product> <Product ProductCode="P2"> <Description>Product 2 Description</Description> <Value EffectiveDate="2006-04-01"> <Price>5.50</Price> <Currency>GB</Currency> </Value> </Product> <Product ProductCode="P3"> <Description>Product 3 Description</Description> </Product> </Interface>
When I read the xml file in with ...Dim ds As DataSet = New DataSet("dataset") ds.ReadXml("prod2.xml") With DataGridView1 .DataSource = ds .DataMember = ds.Tables(2).TableName End With
... I can see that I've got 3 x tables ... "Interface", "Product", "Value". What I'm wondering is how do I get the "Value" table linked to "Product"? I was expecting (rightly or wrongly) to see some inherited values from product displayed in my DataGridView. Looking at the structure of the XML file, it seems to imply that there should be some inheritance???By the look of things, the table Value is already linked to Product, the problem is just that this example only contains data (price, currency, etc) for Product 2.
My advice is free, and you may get what you paid for.