XmlDoc := OXmlPDOM.CreateXMLDoc;
XmlStream := TMemoryStream.Create;
SourceURL := ....;
try
IdHTTP1.Get(SourceUrl, XmlStream);
XmlStream.Position := 0;
XmlDoc.LoadFromStream(XmlStream);
XmlDoc.DocumentElement.SelectNodes('...', GameNodes, 0);
except
on E: Exception do begin
..........
Exit;
end;
end;
for n := 0 to GameNodes.Count - 1 do begin
GameNode := GameNodes.Nodes[n];
Game := GameNode.Attributes['g'];
L := GameNode.ParentNode.Attributes['l']; // go up
Z := GameNode.SelectNode('z').NodeValue; // go down
end;
And if there are all attributes and nodes in xml that i'm searching - all is working fine, really nice, but let's say that node for z is missing, then i get this error:
Access violation at address 006AAB1A in module .... Read Of address 00000000.
In debbuger i get error on this line:
xXPaths := TXMLXPathList.Create(TXMLXPathDOMAdapter.Create(OwnerDocument));
Can someone pls help? I've tried few others parsers, but this one is really cool, just have to make it work :0...
Last edit: Anonymous 2014-08-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
First of all, great parser :) But i have a problem in Delphi XE6...
This is my code...
And if there are all attributes and nodes in xml that i'm searching - all is working fine, really nice, but let's say that node for z is missing, then i get this error:
Access violation at address 006AAB1A in module .... Read Of address 00000000.
In debbuger i get error on this line:
xXPaths := TXMLXPathList.Create(TXMLXPathDOMAdapter.Create(OwnerDocument));
Can someone pls help? I've tried few others parsers, but this one is really cool, just have to make it work :0...
Last edit: Anonymous 2014-08-08
SelectNode('z') returns NIL if the 'z' node does not exist. Of course "SelectNode('z').NodeValue" throws an access violation then.
Please read the documentation in the sources (= comments at the declaration of the functions/properties).