I\'m trying to locate the value for in the following XML File using a XPath query.
In the end I used OmniXML with the following code.
uses
OmniXML, OmniXMLUtils, OmniXMLXPath;
...
function GetResultsURL(Filename: string): string;
var
FXMLDocument: IXMLDocument;
XMLElementList: IXMLNodeList;
XMLNode: IXMLNode;
XMLElement: IXMLElement;
i: integer;
begin
//Create and load the XML document
FXMLDocument := CreateXMLDoc;
FXMLDocument.Load(Filename);
//We are looking for:
XMLElementList := FXMLDocument.GetElementsByTagName('Link');
for i := 0 to Pred(XMLElementList.Length) do
begin
//Check each node and element
XMLNode := XMLElementList.Item[i];
XMLElement := XMLNode as IXMLElement;
if XMLElement.GetAttribute('role') = 'output' then
if Pos('failed', XMLNode.Text) > 0 then
Result := XMLNode.Text;
end;
end;
The XML received looks like this ...
...
12345
https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/12345
https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/12345/output/failed
Completed
2011-04-04T03:57:49.0534147-07:00
2011-04-04T03:58:43.709725-07:00
1
1
1
...