Delphi and XPath Functions

Is it possible to use the Xpath node set function position () function in Delphi's selectNodes () function to select only a certain number of items from a node list? If I like this:

selectNodes('Item[1]') 

      

its all great and i get the item at index 1, but when i try

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

      

I am getting an "unknown method" exception when I try

selectNodes('Item[<10]') 

      

I am getting "unexpected token <". I am using delphi7 and I also imported the new type library into my project with newer versions of msxml.

+1


source to share


3 answers


This is not a Delphi question I think, but MSXML. Check out MSXML documents, or rather MS XPath documents .



Hmm, according to the XPath examples posted on MSDN, " Item[position() &lt; 10]

" should work, at least if " Item

" is the name of the element you are after ...

+1


source


selectNodes requires a string, so you should try:

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

      



Or any xpath query.

0


source


Could this be a version issue? I imported typelibrary from MS XML 6 and got no errors.

0


source







All Articles