DocumentBase.CustomXMLParts Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the custom XML parts in the document.
public Microsoft.Office.Core.CustomXMLParts CustomXMLParts { get; }
Property Value
A Microsoft.Office.Core.CustomXMLParts collection that contains the custom XML parts in the document.
Examples
The following code example embeds employee data in the document by adding a Microsoft.Office.Core.CustomXMLPart to the CustomXMLParts collection in the current document. To use this example, run it from the ThisDocument class in a document-level project.
private void AddCustomXmlPartToDocument()
{
string xmlString =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<employees xmlns=\"http://schemas.microsoft.com/vsto/samples\">" +
"<employee>" +
"<name>Karina Leal</name>" +
"<hireDate>1999-04-01</hireDate>" +
"<title>Manager</title>" +
"</employee>" +
"</employees>";
Office.CustomXMLPart employeeXMLPart = this.CustomXMLParts.Add(xmlString, missing);
}
Private Sub AddCustomXmlPartToDocument()
Dim xmlString As String = _
"<?xml version=""1.0"" encoding=""utf-8"" ?>" & _
"<employees xmlns=""http://schemas.microsoft.com/vsto/samples"">" & _
"<employee>" & _
"<name>Karina Leal</name>" & _
"<hireDate>1999-04-01</hireDate>" & _
"<title>Manager</title>" & _
"</employee>" & _
"</employees>"
Dim employeeXMLPart As Office.CustomXMLPart = _
Me.CustomXMLParts.Add(xmlString)
End Sub
Remarks
For more information about using custom XML parts in Office projects, see Custom XML Parts Overview.