User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 426,574 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,662 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums

XMLDocument - Eeek

Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Help XMLDocument - Eeek

  #1  
Jul 20th, 2006
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 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
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 9:43 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC