4

Good day! I'm working with Delphi 2009 and MSXML2_TLB library (IXMLDOM). I need to select the last Meeting node:

Doc := CreateOleObject('Microsoft.XMLDOM') as IXMLDomDocument;
Doc.loadXML(XmlStr);
tmpNode:= Doc.selectSingleNode('//Meeting[last()]');

But on the last line of the code above I get exception:

Project test.exe raised exception class EOleException with message: 'Unknown method
//Meeting[-->last()<--]'

Is there a way how to select the last node using xpath or do I really have to write code to get node list and then select the last element?

Yet a version info:

Type Lib: C:\WINDOWS\system32\msxml6.dll (1)
LIBID: {F5078F18-C551-11D3-89B9-0000F81FE221}
HelpString: Microsoft XML, v6.0

Thank you in advance! Vojtech

Vojtech
  • 2,533
  • 9
  • 34
  • 65

1 Answers1

5

This is because you are using a version of msxml where the last function is not defined, as far I know this function was introduced in the v 4.0 of MSXML

try

Doc := CreateOleObject('Msxml2.DOMDocument.6.0') as IXMLDomDocument;
RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • The last() function is in W3C XPath, not in the 1998 dialect of XPath that Microsoft introduced in MSXML, and which still, as far as I know, is the default, even though they have supported real XPath for years. – Michael Kay Feb 07 '12 at 18:19