procedure TForm1.Button1Click(Sender: TObject);
var
I : IXMLXmlType;
K : IXMLSchemaType;
L,M,N : IXMLNode;
MyA : TXMLAttributeType;
XMLDocumeNt2 : TXMLDocument;
tempStr : TStrings;
q : integer;
myInfo : TDOMVendor;
begin
tempStr := TStringList.Create;
RemoveDuplicates := TStringList.Create;
Memo1.clear;
memo1.Lines.LoadFromFile('C:\testrds.xml');
tempStr.AddStrings(memo1.Lines);
XMLDocument2 := TXMLDocument.Create('');
xmldocument1.active := false;
XMLDocument1.FileName := '';
XMLDocument2.XML := (tempStr);
xmlDocument2.Active := true;
memo1.Clear;
memo1.Lines.addStrings(XMLDocumeNt2.XML); <-prints out xml fine
Treeview1.Items.Clear;
DomToTree (XMLDocument2.DocumentElement, nil); <-access violation
end;
Please not that DOMTOTree just parses the Document and places it into a
treeview. If anyone has an idea, i would appreciate the help.
steve paplanus
"Steven Paplanus" <sapap...@msn.com> wrote in message
news:3be1ab1c_2@dnews...
steve
"Michael Pham" <mph...@mediaone.net> wrote in message
news:3be1c87a$1_2@dnews...
> I am trying to create an app that creates a TXMLDocument at runtime. It is
> initialized with a ADO recordset that was saved in an XML format to a
> WideString. It seems to load it right into the XMLDocument, but when I try
> to do a XMLDocument2.DocumentElement, it gives me an access violation.
When dynamically creating a TXMLDocument you should always assign the result to
an IXMLDocument interface. If TXMLDocument is used as a component, then it's
lifetime is managed by it's owner, if it's created with no owner, then it's
lifetime is manged through the IXMLDocument interface.
Mark
Well, what a lucky man i am. Just the answer to the question, i was about
to ask.
I now have the following construction:
var
XMLDocument: IXMLDocument;
begin
XMLDocument := TXMLDocument.Create(NIL);
....
Can you tell me, how do i 'free' the XMLDocument after use?
--
Med venlig hilsen / Best regards
Stig Johansen
li...@w3data.dk
Being an interface, it'll be freed automatically. In your example, if it's a
local variable, it'll get freed when the function returns. You can explicitly
free it by saying XMLDocument := nil;.
Mark
Hi.
Thanks, It is a local variable, but resides in a function in a
multithreaded/pooled/wsdl/soap server app, so i am just 'scared' of memory
leaks.
So i think i will free it explicitly.