XmlDocuments selectsinglenode...

D

Daniel Bass

Hi all,

[ Scenario ]
I've got a scenario where I revert from a string, into an XmlDocument with
the LoadXml method.
From here I use the SelectSingleNode to get some node within the Xml Dom
returned to me.
I then make alterations to the XmlNode (add and change some attributes...).
Now I fall back into the string realm using the OuterXml property.

[ Question ]
My question is, does this SelectSingleNode provide me with a reference (or
in C++ a pointer) to the XmlDocument, so that changes I make to the XmlNode,
are reflected in the XmlDocument, because the XmlNode is still referencing
the original object?
Or is it the case that calling SelectSingleNode returns me a copy of the
XmlNode at this address, so that changes made are not reflected on the
XmlDocument?
In this way, can I simply call the OutXml on the XmlDocument which I
originally loaded the string into, or should I call the "OuterXml" property
on the "OwnerDocument" of the XmlNode?

Thanks for your time.

Daniel.
 
N

Nicholas Paldino [.NET/C# MVP]

Daniel,

The xml node is attached to the XmlDocument that it came from. Any
change that you make to the node will be reflected in the document. If you
get the XML of the main document instance after changing the node, it will
be reflected in the xml output.

Hope this helps.
 
D

Daniel Bass

Grand, that's what I needed to know.

Thanks! =o)


Nicholas Paldino said:
Daniel,

The xml node is attached to the XmlDocument that it came from. Any
change that you make to the node will be reflected in the document. If you
get the XML of the main document instance after changing the node, it will
be reflected in the xml output.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

"Daniel Bass" <DanielBass TAKE at OUT CAPS WORDS Postmaster.co.uk> wrote in
message news:OjWH$%[email protected]...
Hi all,

[ Scenario ]
I've got a scenario where I revert from a string, into an XmlDocument with
the LoadXml method.
From here I use the SelectSingleNode to get some node within the Xml Dom
returned to me.
I then make alterations to the XmlNode (add and change some attributes...).
Now I fall back into the string realm using the OuterXml property.

[ Question ]
My question is, does this SelectSingleNode provide me with a reference (or
in C++ a pointer) to the XmlDocument, so that changes I make to the XmlNode,
are reflected in the XmlDocument, because the XmlNode is still referencing
the original object?
Or is it the case that calling SelectSingleNode returns me a copy of the
XmlNode at this address, so that changes made are not reflected on the
XmlDocument?
In this way, can I simply call the OutXml on the XmlDocument which I
originally loaded the string into, or should I call the "OuterXml" property
on the "OwnerDocument" of the XmlNode?

Thanks for your time.

Daniel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top