views:

1260

answers:

3

Can I use Xpath node set function position() in Delphi's function selectNodes() to select only a certain number of element from a node list? If I do like this:

selectNodes('Item[1]')

its all fine and I get the element with index 1, but when I try

selectNodes('Item[position()<10]')

I get exception 'unknown method', when I try

selectNodes('Item[<10]')

I get 'unexpected token <'. Im using delphi7 and I also imported new type library into my project with newer versions of msxml.

A: 

selectNodes requires a string, so you should try:

selectNodes('Item[position()<10]')

Or whatever xpath query.

Gamecat
That was my first impulse too at first but this would be a compile-time error and I don't think that's what the OP got. I think he just left out the quotes.
Oliver Giesen
correct, im using string of course otherwise i would get errors on compiling. I edited my post.
Tamm
+1  A: 

This is not really a Delphi question I think, but an MSXML one. Check the MSXML docs or rather the MS XPath docs.

Hmm, according to the XPath examples posted on MSDN "Item[position() &lt; 10]" should have worked, at least if "Item" is the name of the element you're after...

Oliver Giesen
Those examples are about xslt.
Tamm
A: 

Could it be a version-issue? I have imported typelibrary from MS XML 6, and gets no error.

Vegar