DocumentBase.CustomXMLParts Property


Returns the custom XML parts in the document.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public CustomXMLParts CustomXMLParts { get; }

Property Value

Type: Microsoft.Office.Core.CustomXMLParts

A Microsoft.Office.Core.CustomXMLParts collection that contains the custom XML parts in the document.

For more information about using custom XML parts in Office projects, see Custom XML Parts Overview.

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=\"\">" +
            "<employee>" +
                "<name>Karina Leal</name>" +
                "<hireDate>1999-04-01</hireDate>" +
                "<title>Manager</title>" +
            "</employee>" +

    Office.CustomXMLPart employeeXMLPart = this.CustomXMLParts.Add(xmlString, missing);
Return to top