I have a DLL that downloads a XML document from a website or a file share and puts it into a TMemoryStream. I then create a TXMLDocument and load the XML from the stream. Like this:
XMLDocument := TXMLDocument.Create(nil);
XMLDocument.Active := true;
Next I need to get one value out of the XML file and carry on doing other stuff, but here comes my problem... When I try to access XMLDocument.DocumentElement I get an Access Violation and I can't figure out why. My code continues like this:
FNewApplicationVersion := XMLDocument.DocumentElement.ChildNodes.FindNode('ApplicationVersion').Text; <------ Throws exception
on E: Exception do begin
ShowMessage('Error: ' + E.Message);
The exception I get is "Access Violation at address 00002000. Read of address 00002000"
My variable declarations look like this:
streamXMLFile : TMemoryStream;
XMLDocument : TXMLDocument;
FNewApplicationVersion : String;
As I mentioned this is a DLL. The same code works fine in a normal application... Any ideas?
I have done the trick with including ActiveX in my uses clause and calling CoInitialize in the initialization section.