WorkbookBase.CustomXMLParts Property

Definition

Gets the collection of custom XML parts in the workbook.

public:
 property Microsoft::Office::Core::CustomXMLParts ^ CustomXMLParts { Microsoft::Office::Core::CustomXMLParts ^ get(); };
public Microsoft.Office.Core.CustomXMLParts CustomXMLParts { get; }
member this.CustomXMLParts : Microsoft.Office.Core.CustomXMLParts
Public ReadOnly Property CustomXMLParts As CustomXMLParts

Property Value

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

Examples

The following code example adds employee data to the document by inserting a new Microsoft.Office.Core.CustomXMLPart in the Microsoft.Office.Core.CustomXMLParts collection. The example then retrieves employee data from the XML part and displays the employee name and hire date on Sheet1.

This example is for a document-level customization.

private void AddCustomXMLPart()
{
    string xmlString =
        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
        + "<employees>"
        + "<employee>"
        + "<name>Karina Leal</name>"
        + "<hireDate>1999-04-01</hireDate>"
        + "</employee>"
        + "</employees>";
    Office.CustomXMLPart employeeXMLPart =
        this.CustomXMLParts.Add(xmlString);

    Globals.Sheet1.Range["A1"].Value2 = employeeXMLPart.SelectSingleNode(
        "/employees[1]/employee[1]/name[1]").Text;
    Globals.Sheet1.Range["A2"].Value2 = employeeXMLPart.SelectSingleNode(
                "/employees[1]/employee[1]/hireDate[1]").Text;
}
Private Sub AddCustomXMLPart()
    Dim xmlString As String = _
        "<?xml version=""1.0"" encoding=""utf-8"" ?>" _
        + "<employees>" _
        + "<employee>" _
        + "<name>Karina Leal</name>" _
        + "<hireDate>1999-04-01</hireDate>" _
        + "</employee>" _
        + "</employees>"
    Dim employeeXMLPart As Office.CustomXMLPart = _
        Me.CustomXMLParts.Add(xmlString)

    Globals.Sheet1.Range("A1").Value2 = employeeXMLPart.SelectSingleNode( _
        "/employees[1]/employee[1]/name[1]").Text
    Globals.Sheet1.Range("A2").Value2 = employeeXMLPart.SelectSingleNode( _
                "/employees[1]/employee[1]/hireDate[1]").Text
End Sub

Remarks

For more information about custom XML parts, see Custom XML Parts Overview.

Applies to