Skip to content

Instantly share code, notes, and snippets.

@ritalin
Last active August 29, 2015 14:07
Show Gist options
  • Save ritalin/c0becf118eee5972bc8b to your computer and use it in GitHub Desktop.
Save ritalin/c0becf118eee5972bc8b to your computer and use it in GitHub Desktop.
<?xml version="1.0" ?>
<configuration>
<appSettings>
<add key="AAA">
<sets>
<add key="AAA_1" value="値1" />
<add key="AAA_2" value="値2" />
<add key="AAA_3" value="値3" />
</sets>
</add>
<add key="BBB">
<sets>
<add key="BBB_1" value="名前1" />
<add key="BBB_2" value="名前2" />
<add key="BBB_3" value="名前3" />
</sets>
</add>
</appSettings>
</configuration>
procedure ReadXml(const filePath: string);
const
xpath_1 = '/configuration/appSettings/add[@key="AAA"]/sets/*';
xpath_2 = '/configuration/appSettings/add';
var
selector: IDOMNodeSelect;
node: IDOMNodeList;
begin
Supports(LoadXMLDocument(filePath).DOMDocument, IDOMNodeSelect, selector);
nodes := selector.selectNodes(xpath_1);
Assert(nodes.Length > 0); // これは通る
node = selector.selectNode(xpath_2);
Supports(node, IDOMNodeSelect, selector);
nodes = selector.SelectNodes('./sets/*');
Assert(nodes.Length > 0); // これは失敗する
nodes = selector.SelectNodes('child::sets/*');
Assert(Assigned(nodes)); // これは失敗する
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment