XML example, from the OmniXML XPath demo:
Harry Potter Learning XML Z OmniXML v lepso prihodnost 2006 Kwe sona standwa sam
Try something like this:
uses XMLDoc, XMLDom, XMLIntf; // From a post in Embarcadero's Delphi XML forum. function selectNode(xnRoot: IXmlNode;const nodePath: WideString): IXmlNode; var intfSelect : IDomNodeSelect; dnResult : IDomNode; intfDocAccess : IXmlDocumentAccess; doc: TXmlDocument; begin Result :=nil; if not Assigned(xnRoot)or not Supports(xnRoot.DOMNode, IDomNodeSelect, intfSelect) then Exit; dnResult := intfSelect.selectNode(nodePath); if Assigned(dnResult) then begin if Supports(xnRoot.OwnerDocument, IXmlDocumentAccess, intfDocAccess) then doc := intfDocAccess.DocumentObject else doc :=nil; Result := TXmlNode.Create(dnResult,nil, doc); end; end; var IDoc: IXMLDocument; INode: IXMLNode; begin IDoc := LoadXMLDocument('.\books.xml'); INode := SelectNode(IDoc.DocumentElement,'/bookstore/book[2]/title'); end; //================================================================================ procedure TForm1.Button1Click(Sender: TObject); var noderef:IXMLDOMNodeRef; root:IXMLDOMNode; Node:IXMLDOMNode; begin XMLDocument1.Active:=true; noderef:=XMLDocument1.DocumentElement.DOMNode as IXMLDOMNodeRef; root:=noderef.GetXMLDOMNode; node:=root.selectSingleNode('node1/node2/node3/node4'); if Assigned(node) then begin ShowMessage(node.attributes.getnameditem('title').text); end; end;