...

View Full Version : xPath question



peph.halmen
03-06-2010, 03:58 PM
hi,
i'm currently working on a project in VB.NET. the xml structure i want to query looks something like this:
<cid>
<c1>
<id></id>
<id></id>
[etc]
</c1>
<c2>
<id></id>
[etc]
</c2>
</cid>

now, would an xpath expression like this
xmldoc.DocumentElement.SelectNodes("/cid/c" & c_index & "//id")
work to select all the "id"-nodes that are childnodes of one specific "c[anynumber]" node, where c_index is the number i want to look at?
sorry for the kinda confusing description, but i dont really know how to explain it better.
thanks a lot,
peph.halmen

Dormilich
03-08-2010, 03:09 PM
if SelectNodes() accepts only an XPath expression, this is certainly wrong. conditions you have to define in []

// final XPath expression
// note that index numbers start with 1

/cid/c[c_index]/id



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum