LoadXML 方法 (Office) CustomXMLPartCustomXMLPart.LoadXML method (Office)

允许模板作者依据 XML 字符串填充 CustomXMLPart 对象。Allows the template author to populate a CustomXMLPart object from an XML string. 如果加载成功,则返回 TrueReturns True if the load was successful.

语法Syntax

表达式LoadXML(XML)expression.LoadXML(XML)

_表达式_一个返回**CustomXMLPart** 对象的表达式。expression An expression that returns a CustomXMLPart object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
XMLXML 必需Required StringString 包含要加载的 XML。Contains the XML to load.

返回值Return value

布尔值Boolean

示例Example

以下示例通过字符串将 XML 加载到自定义 XML 部件中。The following example loads XML into a custom XML part from a string.

Sub ShowCustomXmlParts() 
    On Error GoTo Err 
 
    Dim cxp1 As CustomXMLPart 
 
        ' Add a custom XML part and then load the XML. 
        Set cxp1 = ActiveDocument.CustomXMLParts.Add 
        cxp1.LoadXML("<discounts><discount>0.10</discount></discounts>") 
     
    Exit Sub 
                 
' Exception handling. Show the message and resume. 
Err: 
        MsgBox (Err.Description) 
        Resume Next 
End Sub

另请参阅See also

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.