XML information is read into memory from different formats. It can be read from a string, stream, URL, text reader, or a class derived from the XmlReader.
The Load method brings the document into memory and has overloaded methods available to take data from each of the different formats. There is also a LoadXml method that reads XML from a string.
Different Load methods affect which nodes are created when the XML Document Object Model (DOM) is loaded. The following table lists the differences between some of the Load methods and topics that address them.
The following example shows XML being loaded with the LoadXml method and the data subsequently saved to a text file called data.xml.
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
' Create the XmlDocument.
Dim doc As New XmlDocument()
doc.LoadXml(("<book genre='novel' ISBN='1-861001-57-5'>" & _
"<title>Pride And Prejudice</title>" & _
"</book>"))
' Save the document to a file.
doc.Save("data.xml")
End Sub 'Main
End Class 'Sample
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
// Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>");
// Save the document to a file.
doc.Save("data.xml");
}
}

See Also