Re: Value/Reference Types - Oooooops!
From: Jerry Morton (JerryMorton233_at_mail.com)
Date: 10/10/04
- Previous message: Paul Eden: "Re: Saving dataset as nested XML"
- In reply to: Martin Honnen: "Re: Value/Reference Types - Oooooops!"
- Next in thread: Martin Honnen: "Re: Value/Reference Types - Oooooops!"
- Reply: Martin Honnen: "Re: Value/Reference Types - Oooooops!"
- Messages sorted by: [ date ] [ thread ]
Date: 10 Oct 2004 11:01:37 -0700
Hi Martin,
I would prefer that the node returned from my function had no
relationship to the private XmlDocument. Can XmlNodes even exist in
isolation like this? i.e. without a parent XmlDocument? I appreciate
that a CLONED node may not cause the same problems (like setting
objNode.InnerXml=string.empty!) however this "cloning" does sound like
a "memory leak waiting to happen"? This object persists for a long
time too...
The purpose of all this is to completely encapsulate a PRIVATE
XmlDocument so that it can't be modified by code outside the class. I
can't be the first person who want to do this :-)
I still can't believe that a private member variable behaves this way.
However, if it does then I can live with making "copies" of the
document to pass back from functions. But does this mean that when I
only want to pass one node of the document, I actually have to pass
back an XmlDocument containing only that node?
Martin Honnen <mahotrash@yahoo.de> wrote in message news:<eO5mqDfrEHA.3172@TK2MSFTNGP10.phx.gbl>...
> Jerry Morton wrote:
>
>
> > public XmlNode GetNodeByID(string sID)
> > {
> > //How do I return a "copy" of an XmlNode - The following line gets a
> > compiler error: "Cannot create an instance of the abstract class or
> > interface 'System.Xml.XmlNode'"
> > XmlNode objNewNode = new XmlNode();
>
> You can clone nodes in the DOM e.g.
> node.CloneNode(true)
> to create a clone. However that cloned node still belongs to the same
> ownerDocument as node so I can currently not assess whether that is of
> any help to you.
> Maybe you can explain in more detail how you want to consume the node
> returned by that method.
- Previous message: Paul Eden: "Re: Saving dataset as nested XML"
- In reply to: Martin Honnen: "Re: Value/Reference Types - Oooooops!"
- Next in thread: Martin Honnen: "Re: Value/Reference Types - Oooooops!"
- Reply: Martin Honnen: "Re: Value/Reference Types - Oooooops!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|