This is being pulled into a dataset using Dataset.ReadXml. The resulting XML has 3 tables, product (empty rows), tier1 (just ids), tier2 (just relations).
To read out all the id's i can simply reference to them using:
myDS.Tables["tier1"].Rows[0].ToString();
To get all the relations, similarly I can use myDS.Tables["tier2"].Rows[0].ToString();
How do I get 2 figures out of this, the relation and it's corresponding id, so the output for the above example would be:
ID: 1 Relation: 2
ID: 2 Relation: Null
This is being pulled into a dataset using Dataset.ReadXml. The resulting XML has 3 tables, product (empty rows), tier1 (just ids), tier2 (just relations).
To read out all the id's i can simply reference to them using:
myDS.Tables["tier1"].Rows[0].ToString();
To get all the relations, similarly I can use myDS.Tables["tier2"].Rows[0].ToString();
How do I get 2 figures out of this, the relation and it's corresponding id, so the output for the above example would be:
ID: 1 Relation: 2
ID: 2 Relation: Null
?
Not sure I'm understanding what your XML is trying to do, but I would go in this direction... (not accurate by any means, but might give you an idea)
Dim i as Int32
Dim j as Int32
Dim _innerRow as DataRow
dim _id as String
dim _relation as String
For i = 0 to myDs.Rows.Count - 1
_innerRow = myDs.Rows(i)
for j = 0 to _innerRow.Rows.Count - 1
_id = _innerRow.Rows(j)(0).ToString
_relation = iif(_innerRow.Rows(j)(1).ToString = String.Empty, DbNull.Value, _innerRow.Rows(j)(1).ToString))
next
Next
this is a data file that holds information i need to visualize, so i'm reverse engineering it. I've got it back to an XML form, and now I need to load data off the XML into a new dataset so I can output a "clean xml" to work with for visualization.
Here is a real world example of the data I'm working with:
I can pull out all the LI->BASICS->LI_KEY and LABEL values quite easily, they're in the same "basics" table in the dataset... i need to pull out all the TK_LI_ID values and their corresponding LI_KEY values, but these values are stored in two different tables bound together by the same LI parent. So in this above example my first clean data table would read: 1140, "Allowed CAB to meet target coverage"
and my 2nd data table would read: 1140, 1132
1140, 62
Last edited by Turbanator on Wed Aug 13, 2008 5:00 pm, edited 1 time in total.
Turbanator wrote:this is a data file that holds information i need to visualize, so i'm reverse engineering it. I've got it back to an XML form, and now I need to load data off the XML into a new dataset so I can output a "clean xml" to work with for visualization.
Here is a real world example of the data I'm working with:
I can pull out all the LI->BASICS->LI_KEY and LABEL values quite easily, they're in the same "basics" table in the dataset... i need to pull out all the TK_LI_ID values and their corresponding LI_KEY values, but these values are stored in two different tables bound together by the same LI parent. So in this above example my first clean data table would read: 1140, "Allowed CAB to meet target coverage"
and my 2nd data table would read: 1140, 1132
1140, 62
The XML looks malformed to me... The children of F_TOKENS are all screwy. Considering those children have different keys, what happens when one of the children is not present? Defaults to null? Seems like it would make your life much easier parsing this data if the children at least matched (with no values if none are present).
the app that builds this data (from which i pull out this XML file from), was developed in 2003... screwy is an understatement, the whole thing is fucked but it is what it is... and I need to get these relationship links out of it :\
to answer your question, the dataset reads them as blank when they're not present... so a simple check of "if ....length > 1 ... then add the item to new dt" would get rid of all the dodgy crap.