I have an application that reads data from an XML file, typically I simply use the "DataTable.ReadXML(sXML)" and then extract the information that I need, but not I need to do it based on a condition and I cant seem to figure out how I can implement it.
For example - I have an XML (C:\file.xml) such as the following:
As you can see, my XML has two divisions (name "A" and "B"), I need to get the Folder information depending on which division I am dealing with. Specifically something like this (pseudo-code):
Now, I have the following code that simply dumps the XML into a DataTable, but I have no clue how, once with the datatable, to extract only the Folders from <Segment Folder=".." /> of the appropriate <Info></Info> from the appropriate <Division Name=".."></Division> where the Division Name matches my search criteria...
Note - I dont need to use DataTable.ReadXML to perform my work, it is simply the easiest way I know how to input an XML file, however I would assume this may no longer suit my needs.
Any help would be greatly appreciated.
Thanks,
For example - I have an XML (C:\file.xml) such as the following:
Code:
<RootNode>
<Stores>
<Division Name="A">
<Info>
<Segment Folder="FolderA1"/>
<Segment Folder="FolderA2"/>
<Segment Folder="FolderA3"/>
</Info>
</Division>
<Division Name="B">
<Info>
<Segment Folder="FolderB1"/>
<Segment Folder="FolderB2"/>
<Segment Folder="FolderB3"/>
</Info>
</Division>
<Stores>
</RootNode>
As you can see, my XML has two divisions (name "A" and "B"), I need to get the Folder information depending on which division I am dealing with. Specifically something like this (pseudo-code):
Code:
if (Division = varX) // where varX is either "A" or "B"
for each (string sFolder in <Segment Folder="..."> in <Info>) // Listing all the Segment Folders from either "A" or "B" depending on varX
... do something with sFolder ...
Now, I have the following code that simply dumps the XML into a DataTable, but I have no clue how, once with the datatable, to extract only the Folders from <Segment Folder=".." /> of the appropriate <Info></Info> from the appropriate <Division Name=".."></Division> where the Division Name matches my search criteria...
Code:
DataSet dsxmlfile = new DataSet();
dsxmlfile.ReadXml(sXML);
DataView dsview = dsxmlfile.Tables["Stores"].DefaultView;
...? stuck here ...?
Note - I dont need to use DataTable.ReadXML to perform my work, it is simply the easiest way I know how to input an XML file, however I would assume this may no longer suit my needs.
Any help would be greatly appreciated.
Thanks,