Not being tricky with XmlDocument

  • Thread starter Thread starter knocte
  • Start date Start date
K

knocte

I am using the XmlDocument class to generate a XML document "on the
fly", I mean, build it in memory so as to extract its contents with the
property "OuterXml".

I know how to create elements and attributes inside these elements, and
text and more elements inside elements... ¡except the first element!
(the DocumentElement). How can I create it? Because I think I am now
using a very "tricky" method...:

using System.Xml;

(...)

XmlDocument miNuevoDocumentoXml = New XmlDocument();
miNuevoDocumentoXml.LoadXml("<ROOT />");

(...)


Is there any other way to create the primary element called ROOT?

Thanks in advance.

Regards,

Andrew
 
knocte said:
I am using the XmlDocument class to generate a XML document "on the fly", I
mean, build it in memory so as to extract its contents with the property
"OuterXml".

I know how to create elements and attributes inside these elements, and
text and more elements inside elements... ¡except the first element! (the
DocumentElement). How can I create it? Because I think I am now using a
very "tricky" method...:

using System.Xml;

(...)

XmlDocument miNuevoDocumentoXml = New XmlDocument();
miNuevoDocumentoXml.LoadXml("<ROOT />");

Try
miNuevoDocumentoXml .DocumentElement =
miNuevoDocumentoXml .CreateElement("ROOT");
 
Back
Top