🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
8 messages
8 total messages Started by Fabi�n Wed, 15 Sep 2004 22:23
deleting a TXMLDocument
#1558
Author: Fabi�n
Date: Wed, 15 Sep 2004 22:23
38 lines
1840 bytes
hi...  I'm creating XMLDocuments dinamicaly, but I don't know how to delete
them. If I use:  delete XMLDocument;     the compiler throws an error.

Can someone helps me?

here is the code

void __fastcall TFMain::ServerSocket1ClientRead(TObject *Sender,
      TCustomWinSocket *Socket)
{
    AnsiString Texto, Evento, Room_id;
    TXMLDocument *XMLDocument;
    _di_IXMLDocument d;
    _di_IXMLNode Nodo;

    XMLDocument = new TXMLDocument("");

    try
    {
      Texto = Socket->ReceiveText();
      Memo1->Lines->Add(Texto);

      try
      {
        XMLDocument->GetInterface(d);
        d->LoadFromXML(WideString(Texto));

        Nodo = XMLDocument->DocumentElement->ChildNodes->GetNode(0);
        Evento = Nodo->Attributes[WideString("name")];
      }
      catch ( ... )
      {
..........
........

    XMLDocument->Active = false;      //I don't know if I need it
    //delete XMLDocument;                  //this trows an error
}
Re: deleting a TXMLDocument
#1560
Author: Hans Galema
Date: Thu, 16 Sep 2004 14:16
13 lines
1361 bytes
Fabi�n wrote:

> hi...  I'm creating XMLDocuments dinamicaly, but I don't know how to delete
> them. If I use:  delete XMLDocument;     the compiler throws an error.

The compiler /throws/ an error ? Or does it report an error ?
What is the exact errormessage ?

>     //delete XMLDocument;                  //this trows an error

At runtime maybe ? Does it AV ? What is the exact errormessage ?

Hans.
Re: deleting a TXMLDocument
#1561
Author: Fabi�n
Date: Thu, 16 Sep 2004 23:45
22 lines
1647 bytes
yes, the error is at runtime...  the classic acces violation at address
000000000....  error reading....

can you help me?


"Hans Galema" <dontusethis@dontusethis.nl> escribi� en el mensaje
news:41499f8e$1@newsgroups.borland.com...
> Fabi�n wrote:
>
> > hi...  I'm creating XMLDocuments dinamicaly, but I don't know how to
delete
> > them. If I use:  delete XMLDocument;     the compiler throws an error.
>
> The compiler /throws/ an error ? Or does it report an error ?
> What is the exact errormessage ?
>
> >     //delete XMLDocument;                  //this trows an error
>
> At runtime maybe ? Does it AV ? What is the exact errormessage ?
>
> Hans.
Re: deleting a TXMLDocument
#1562
Author: Hans Galema
Date: Fri, 17 Sep 2004 07:18
20 lines
1642 bytes
Fabi�n wrote:
> yes, the error is at runtime...  the classic acces violation at address
> 000000000....  error reading....

You only delete XMLDocument in case there is a catch.
You are executing this code in ServerSocket1ClientRead().

In case there is no catch what does delete XMLDocument; do ?

What has this AV to do with ServerSocket1ClientRead() and with a
failing try ?

What I like to know if you just have the two statements

	XMLDocument = new TXMLDocument("");
	delete XMLDocument;

in for instance an TButton's OnClick handler, if you then get the same error.

Hans.
Re: deleting a TXMLDocument
#1563
Author: Fabi�n
Date: Sat, 18 Sep 2004 04:23
91 lines
3360 bytes
I didn't explained the code I send very well.
I delete the xmldocument allways.  After the catch there is a lot of code
that reads the xml.

If I put this in a button

 XMLDocument = new TXMLDocument("");
 delete XMLDocument;

it works....

but this trows an error at runtime:

    AnsiString Texto, Evento, Room_id;
    TXMLDocument *XMLDocument;
    _di_IXMLNode Nodo;

    XMLDocument = new TXMLDocument("");

    try
    {
      Texto = Socket->ReceiveText();
      Memo1->Lines->Add(Texto);

      try
      {
        XMLDocument->LoadFromXML(WideString(Texto));

        Nodo = XMLDocument->DocumentElement->ChildNodes->GetNode(0);  //here
        Evento = Nodo->Attributes[WideString("name")];
        (...)


I readed somewhere that this error happends because ther is a problem with
the sincronization or something like that.
so I use this code that works fine:

    AnsiString Texto, Evento, Room_id;
    TXMLDocument *XMLDocument;
    _di_IXMLDocument d;
    _di_IXMLNode Nodo;

    XMLDocument = new TXMLDocument("");

    try
    {
      Texto = Socket->ReceiveText();
      Memo1->Lines->Add(Texto);

      try
      {
        XMLDocument->GetInterface(d);
        d->LoadFromXML(WideString(Texto));

        Nodo = XMLDocument->DocumentElement->ChildNodes->GetNode(0);
        Evento = Nodo->Attributes[WideString("name")];

but i can not delete  XMLDocument.

I think that the problem in this line:  XMLDocument->GetInterface(d);

well... the problem is very strange...

I hope you can help me.

Fabi�n


"Hans Galema" <dontusethis@dontusethis.nl> escribi� en el mensaje
news:414a8efe@newsgroups.borland.com...
> Fabi�n wrote:
> > yes, the error is at runtime...  the classic acces violation at address
> > 000000000....  error reading....
>
> You only delete XMLDocument in case there is a catch.
> You are executing this code in ServerSocket1ClientRead().
>
> In case there is no catch what does delete XMLDocument; do ?
>
> What has this AV to do with ServerSocket1ClientRead() and with a
> failing try ?
>
> What I like to know if you just have the two statements
>
> XMLDocument = new TXMLDocument("");
> delete XMLDocument;
>
> in for instance an TButton's OnClick handler, if you then get the same
error.
>
> Hans.
Re: deleting a TXMLDocument
#1564
Author: Hans Galema
Date: Sat, 18 Sep 2004 08:23
19 lines
1608 bytes
Fabi�n wrote:

>  XMLDocument = new TXMLDocument("");
>  delete XMLDocument;
> 
> it works....
> 
> but this trows an error at runtime:

That is much to much code below. I said that before. If you want
to debug your code and find the error then continue with
the above two lines. Add statements one by one and test
for every new statement. Do NOT read from a socket. Take
a fixed (Ansi)String. Do not add text to a memo. Only code
the bare necessities.

Please trim quotes.

Hans.
Re: deleting a TXMLDocument
#1566
Author: Remy Lebeau (TeamB)
Date: Mon, 20 Sep 2004 22:35
44 lines
2341 bytes
"Fabi�n" <fabianfierro@hotmail.com> wrote in message
news:4148c0b5@newsgroups.borland.com...

> hi...  I'm creating XMLDocuments dinamicaly, but I don't know
> how to delete them. If I use:  delete XMLDocument;     the
> compiler throws an error.

TXMLDocument is a special-case class.  It does not act like other classes.
When dropped onto a form at design-time, it acts like a component.  When
instantiated dynamically at runtime, it acts like an interface instead.  As
such, you should not instantiate TXMLDocument dynamically at all.  Use the
IXMLDocument interface directly instead, via the NewXMLDocument() function.
For example:

    void __fastcall TFMain::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
    {
        AnsiString Texto, Evento, Room_id;
        _di_IXMLDocument XMLDocument;
        _di_IXMLNode Nodo;

        Texto = Socket->ReceiveText();
        Memo1->Lines->Add(Texto);

        XMLDocument = NewXMLDocument("");
        try
        {
            XMLDocument->LoadFromXML(Texto);
            Nodo = XMLDocument->DocumentElement->ChildNodes->GetNode(0);
            Evento = Nodo->Attributes["name"];
        }
        catch (const Exception &)
        {
            //...
        }
    }

When the _di_IXMLDocument wrapper goes out of scope, it will automatically
free the IXMLDocument for you, the same thing that the _di_IXMLNode wrapper
does for the IXMLNode as well.


Gambit
Re: deleting a TXMLDocument
#1567
Author: Fabi�n
Date: Tue, 21 Sep 2004 22:05
59 lines
2748 bytes
You are a genious!!

you are allways right...  i hope some day can be like you (in my dreams)...

Thanks!

Fabi�n

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> escribi� en el mensaje
news:414f5a90$1@newsgroups.borland.com...
>
> "Fabi�n" <fabianfierro@hotmail.com> wrote in message
> news:4148c0b5@newsgroups.borland.com...
>
> > hi...  I'm creating XMLDocuments dinamicaly, but I don't know
> > how to delete them. If I use:  delete XMLDocument;     the
> > compiler throws an error.
>
> TXMLDocument is a special-case class.  It does not act like other classes.
> When dropped onto a form at design-time, it acts like a component.  When
> instantiated dynamically at runtime, it acts like an interface instead.
As
> such, you should not instantiate TXMLDocument dynamically at all.  Use the
> IXMLDocument interface directly instead, via the NewXMLDocument()
function.
> For example:
>
>     void __fastcall TFMain::ServerSocket1ClientRead(TObject *Sender,
> TCustomWinSocket *Socket)
>     {
>         AnsiString Texto, Evento, Room_id;
>         _di_IXMLDocument XMLDocument;
>         _di_IXMLNode Nodo;
>
>         Texto = Socket->ReceiveText();
>         Memo1->Lines->Add(Texto);
>
>         XMLDocument = NewXMLDocument("");
>         try
>         {
>             XMLDocument->LoadFromXML(Texto);
>             Nodo = XMLDocument->DocumentElement->ChildNodes->GetNode(0);
>             Evento = Nodo->Attributes["name"];
>         }
>         catch (const Exception &)
>         {
>             //...
>         }
>     }
>
> When the _di_IXMLDocument wrapper goes out of scope, it will automatically
> free the IXMLDocument for you, the same thing that the _di_IXMLNode
wrapper
> does for the IXMLNode as well.
>
>
> Gambit
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads