Either I'm doing something very wrong, or the XMLDocument component is a terribly written component. I keep getting Access violation at #ADDRESS Read Of #ADDRESS errors, no explanation just a peek at the CPU showing the error occurs all of the place depending on which test I'm doing. Basically, all I want to do is look at the document, and see if the correct node is one of a list of child nodes, the documents below are very scaled down from what I'm trying to use, but if it isn't working at this scale it isn't gonna work at any.
All attempts to either search for the node with name vtest or check the name of the node that contains the data within vtest result in access violations. All attempts to read nodes any deeper than the top level result in access violations, doing anything with DocumentElement causes access violations, although something with that did work about an hour ago, still, the command was about n1.n2....n8 dots deep, and would only return the same data/access violation pattern as with any other attempt.
The tests below are the results when trying to assign the leftside function to anything, specifically though, i'm adding it to a listbox directly/inline.
What's up with this? It seems like it's capable of doing what I want it to, infact, it seems like its being deliberately malicious :P xml isn't much use if it can't cope with custom tags.
Here's the code from my procedure:
var
XMLPath : String;
XMLReader : TXMLDocument;
iNode : Integer;
begin
XMLPath := NetPath + AppendPath + 'version.xml';
XMLReader := TXMLDocument.Create(nil);
XMLReader.LoadFromFile(XMLPath);
XMLReader.Active := True;
Status.AddItem(**COMMANDSBELOW*, nil);
end;
With document
<?xml version="1.0" encoding="iso-8859-1"?>
<vtest>test</vtest>
Results XMLReader.ChildNodes[1].Text
- Returns 'test', all seems good. XMLReader.Node.NodeName
- Returns '#document', that isn't anywhere in the document, but ok. XMLReader.ChildNodes[0].NodeName
- Returns 'xml', which is the name of the document header, fair enough. XMLReader.ChildNodes[1].NodeName
- Access Violation, no explanation of why XMLReader.ChildNodes[2].NodeName
- Exception, index (2) is out of bounds, index 2 doesn't exist, so fair enough. XMLReader.ChildNodes.FindNode('xml').Text
- as expected; version="1.0" encoding="iso-8859-1" XMLReader.ChildNodes.FindNode('vtest').Text
- Access Violation, no explanation of why XMLReader.DocumentElement.XML
- Access violation XMLReader.ChildNodes[0].XML
- <?xml version="1.0" encoding="iso-8859-1"?> XMLReader.ChildNodes[1].XML
- Access violation
And With document
<?xml version="1.0" encoding="iso-8859-1"?>
<vtest><vtest2>test<vtest2></vtest>
Results XMLReader.ChildNodes[1].ChildNodes[0].Text
- Access Violation