Sorry, I forgot to mention that when using chaining, current node should be passed to XPath as parameter to prevent XPath walking up toi root.
var D: THtmlNode;
N, A: THtNode;
begin
D := THtmlNode.Create;
try
D.Parse('<body><h1 id="header1"<a href="a1">First</a><a href="a2">Second</a></h1><h2><div><a href="a3">Third</a></div></h2></body>');
for N in D.XPath('//h1[@id="header1"]') do
for A in N.XPath('//a', false, N) do
ShowMessage(A['href']);
for N in D.XPath('//h2') do
for A in N.XPath('//a', false, N) do
ShowMessage(A['href']);
finally
D.Free
end;
Second parameter is "stop after first found node", third is current root node.