1

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.

3 Answers 3

1

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...

Sign up to request clarification or add additional context in comments.

1 Comment

Those examples are about xslt.
0

selectNodes requires a string, so you should try:

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

Or whatever xpath query.

2 Comments

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.
correct, im using string of course otherwise i would get errors on compiling. I edited my post.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.