this is my xml file (content.xml):
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head></head>
<body>
<h1>Lorem ipsum dolor sit amet</h1>
</body>
</html>
that is my code in Delphi (XE5):
procedure TForm1.Button1Click(Sender: TObject);
var
doc: IXMLDocument;
Sel: IDOMNodeSelect;
List : IDOMNodeList;
query: String;
begin
content := TFile.ReadAllText('C:\temp\content.xml');
doc := TXMLDocument.Create(Application);
doc.LoadFromXML(content);
doc.Active := True;
query := '//descendant::html';
Sel := doc.DOMDocument as IDomNodeSelect;
List := Sel.selectNodes(query);
// List.length is 0 !!!!
end;
The question why List is empty, shoud contain four elements: HTML, head, body, h1(that's "html" tag and all its children. According to http://www.w3schools.com/xpath/xpath_syntax.asp XPath syntax I've tried that options:
//html/*
/html
/html/*
none of them Works for me so at this point I do not know if the query is ok or my code fails in another point.