XPath in Delphi7?

What is the best way to search for XML documents using XPath in Delphi7?

+5
source share
2 answers

It depends on the size of the xml document. But I have good experience with MSXML and its Saxon colleague.

If xml is large (> 50 MB) or requests are heavy (use some // to bypass the system), expect some delay time. But otherwise it is quite doable.

In later versions, msxml is available as a unit. In version 7, you need to install a type library:

  • Go to the project type library \ Import
  • Choose Microsoft XML (the highest version you can find)
  • Select Create unit to create MSXML_TLB

You can use MSXML_TLB to read XML documents, use xslt, and execute xpath requests:

var doc : IXMLDomDocument2; list : IXMLDomNodeList; node : IXMLDomNode; i : Integer; begin doc := CoDOMDocument.Create; doc.load(xmlfilename); list := doc.selectNodes(xpath); for i := 0 to list.length-1 do begin node := list.item[i]; if node<>nil then Memo1.Lines.Add(node.nodeName); end; end; 
+6
source

When I have to deal with XML files in Delphi, I always use OmniXML , a component that I have used for many years. I am completely satisfied with this, mainly because it is lightweight, easy to use and free .

And it also works with XPath. It's worth a try, I hope this helps too.

+1
source

Source: https://habr.com/ru/post/913399/


All Articles