Ich kenne dein Testwerkzeug nicht. Hier ist meins:
Delphi-Quellcode:
program XPath;
{$APPTYPE CONSOLE}
uses
ActiveX,
Msxml2,
SysUtils;
var
doc: IXMLDOMDocument2;
function NodeList(doc: IXMLDOMDocument2; xp:
string): IXMLDOMDocument2;
var
i: Integer;
nl: IXMLDOMNodeList;
begin
Result := CoDomDocument.Create;
Result.async := False;
nl := doc.documentElement.selectNodes(xp);
Result.documentElement := Result.createElement('
nodelist');
for i := 0
to Pred(nl.length)
do
Result.documentElement.appendChild(nl.item[i].cloneNode(True));
end;
begin
if ParamCount <> 3
then
begin
WriteLn('
usage: xpath pathexpr xmlinput xmloutput');
Halt;
end;
CoInitialize(
nil);
doc := CoDomDocument.Create
as IXMLDOMDocument2;
doc.async := False;
if doc.load(ParamStr(2))
then NodeList(doc, ParamStr(1)).save(ParamStr(3))
else WriteLn(doc.parseError.reason);
CoUninitialize;
end.
Freundliche Grüße