|
Mailing Lists
|
Home /
Groups /
.NET Technical Talk (Net-Talk)
Help with XML Parsing
Author: G
Short Link: http://www.houseoffusion.com/groups/net-talk/thread.cfm/threadid:1699#5351
I'm no expert on this, but aren't the nodes just children of the particular
node you are on? So in your loop, can't you use . notation to get at the
children, something like:
node.cake
node.cake.filling
etc...?
Hi, I'm trying to iterate over an xml doc and then access some values. I've
got the iterate part down but accessing the values slightly deeper seems to
be beyond me. So, with this xml in mind,
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<cake>
<filling>
<fruit>strawberry</fruit>
</filling>
<icing>
<fruit>apple</fruit>
</icing>
</cake>
</item>
<item>
.....
</item>
<item>
.....
</item>
</items>
I loop over the items like so :
XmlNodeList fileNodeList = xmldoc.SelectNodes("//item");
foreach (XmlNode node in fileNodeList) {
But then how do I reach in and grab the values for the fruit?
}
I've tried selectChildren and all sorts of similar but I cant quite figure
it out. Any help greatly appreciated.
Author: Andre Turrettini
Short Link: http://www.houseoffusion.com/groups/net-talk/thread.cfm/threadid:1699#5350
Hi, I'm trying to iterate over an xml doc and then access some values. I've got
the iterate part down but accessing the values slightly deeper seems to be beyond
me. So, with this xml in mind,
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<cake>
<filling>
<fruit>strawberry</fruit>
</filling>
<icing>
<fruit>apple</fruit>
</icing>
</cake>
</item>
<item>
....
</item>
<item>
....
</item>
</items>
I loop over the items like so :
XmlNodeList fileNodeList = xmldoc.SelectNodes("//item");
foreach (XmlNode node in fileNodeList) {
But then how do I reach in and grab the values for the fruit?
}
I've tried selectChildren and all sorts of similar but I cant quite figure it
out. Any help greatly appreciated.
|
May 23, 2013
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||