-
April 20th, 2007, 09:32 AM
#1
XML SelectNodes (Position)
Is there any way to select a node by its position in an xml document? The example would be something like this:
<Element Name="Element1">
<Value Name="Value1"/>
<Value Name="Value2"/>
<Value Name="Value3"/>
</Element>
<Element Name="Element2">
<Value Name="Value4"/>
<Value Name="Value5"/>
<Value Name="Value6"/>
</Element>
<Element Name="Element3">
<Value Name="Value7"/>
<Value Name="Value8"/>
<Value Name="Value9"/>
</Element>
And I need to select the third child of every Element. So the returned set of nodes would be Value3,Value6, and Value9. I tried something like this:
dim xml as string 'set to xml example above
dim xmlDoc as freethreadeddomdoc30
set xmldoc = new freethreadeddomdoc30
xmldoc.loadxml xml
xmldoc.selectnodes(".//Element/Value[position()=3]")
I've tried every possible syntax that I can think of to accomplish this, and can't get it right. Anyone know how to go about doing this?
-
April 20th, 2007, 10:16 AM
#2
Re: XML SelectNodes (Position)
I'm not sure if you can do this with a single xpath. If you find a solution, please let me know! But it would seem that you first have to get each element and then select its third value.
I think it depends on the order of operation. If the data were returned or filtered as some kind of matrix, where it kept an array of Elements and each array of Elements had its own Value array, then I could see doing something like what you're trying. But as far as I know, it returns your data as a single list of nodes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|