XMLNode.LoadXml Method (XmlDocument)
Populates an XMLNode control with data from the root node of the specified XmlDocument.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)
Syntax
'Declaration
Sub LoadXml ( _
document As XmlDocument _
)
void LoadXml(
XmlDocument document
)
Parameters
document
Type: System.Xml.XmlDocumentThe XmlDocument that contains the data.
Remarks
This method does not add additional XMLNode controls or delete unnecessary XMLNode controls from the document.
This method updates all attributes of the XMLNode control.
Examples
The following code example uses the LoadXml method to fill an XMLNode with data from an XmlDocument. The example reads the contents of an XML file into a StreamReader, loads this StreamReader into an XmlDocument, and then uses the XmlDocument for the document parameter of the LoadXml method. This example assumes that the current document contains an XMLNode named CustomerNode. This example also assumes that an XML file named Customers.xml, which conforms to the schema associated with CustomerNode, exists at the root of the D directory.
Private Sub LoadXmlFromXmlDocument()
Dim xmlPath As String = "D:\Customers.xml"
Dim xmlStreamReader As New System.IO.StreamReader(xmlPath)
Dim xmlDoc As New System.Xml.XmlDocument()
xmlDoc.Load(xmlStreamReader)
Me.CustomerNode.LoadXml(xmlDoc)
End Sub
private void LoadXmlFromXmlDocument()
{
string xmlPath = @"D:\Customers.xml";
System.IO.StreamReader xmlStreamReader =
new System.IO.StreamReader(xmlPath);
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(xmlStreamReader);
this.CustomerNode.LoadXml(xmlDoc);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.