将指定的 XML 插入文档中的指定区域,并且替换该区域中包含的任何文本。
语法
表达式.InsertXML(XML, Transform)
表达式 一个返回 Range 对象的表达式。
参数
名称 |
必选/可选 |
数据类型 |
说明 |
XML |
必选 |
String |
指定要插入的 XML。这可以是任何有效的自定义 XML。 |
Transform |
可选 |
Variant |
指定用于转换 XML 的 XML 转换 (XSLT)。如果省略,则将 XML 作为自定义 XML 插入,而不应用转换。 |
返回值
无
示例
以下示例将指定的 XML 字符串插入文档中的第五段。这将替换第五段中包含的任何文本。
示例代码 |
let strXML = '<?xml version=""1.0""?><abc:books xmlns:abc=""urn:books"" '
+ 'xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "'
+ 'xsi:schemaLocation=""urn:books books.xsd""><book>'
+ '<author>Matt Hink</author><title>Migration Paths of the Red '
+ 'Breasted Robin</title><genre>non-fiction</genre>'
+ '<price>29.95</price><pub_date>2006-05-01</pub_date>'
+ '<abstract>You see them in the spring outside your windows. '
+ 'You hear their lovely songs wafting in the warm spring air. '
+ 'Now follow their path as they migrate to warmer climes in the fall, '
+ 'and then back to your back yard in the spring.</abstract></book></abc:books>'
ActiveDocument.Paragraphs.Item(5).Range.InsertXML(strXML)
|