DocumentBase.CustomXMLParts 属性

定义

返回文档中的自定义 XML 部件。

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

属性值

一个 Microsoft.Office.Core.CustomXMLParts 集合,其中包含文档中的自定义 XML 部件。

示例

下面的代码示例通过将 添加到 Microsoft.Office.Core.CustomXMLPart 当前文档中的 集合,在 CustomXMLParts 文档中嵌入员工数据。 若要使用此示例,请从文档级项目中的 ThisDocument 类运行它。

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

注解

有关在 Office 项目中使用自定义 XML 部件的详细信息,请参阅 自定义 XML 部件概述

适用于