How to Load XML Documents in ASP.NET 2.0 - Loading an XMLDocument (Page 2 of 4 )
The five different Load() methods shown in the above picture surrounded by a red rectangle will be explored with code to show how each of them may be used to load the XMLDocument. The various methods are used in a web site project, XMLSite. The XMLDocument gets instantiated and loaded in the click event of a button. All of the examples use the same XML file which has been used in other XML related tutorials by the author on the DevArticles.com and ASPFree.com web sites.
LoadXml (string) method
After instantiating an XMLDocument using the New keyword you can invoke the LoadXml() method with the XML file in a string format as an argument as shown in the following picture. Also observe that the argument to the method typed in is an XML file content in a string format.

Once the XML document is loaded you can invoke its properties through the XML DOM Model to verify if the content is loaded correctly. This may be simply tested as shown by the completed code and the output written as a Response.Write() as shown.
Response.Write(xmldoc.HasChildNodes)
Response.Write("<br/>")
Response.Write(xmldoc.DocumentElement.LastChild.InnerXml)
Response.Write("<br/>")
The result of running the above in the IE browser is as shown in the next picture.

Next: Load (string) where string is an XML file >>
More ASP.NET Code Articles
More By Jayaram Krishnaswamy