Selection.InsertXML メソッド (Word)

文書のカーソル位置に指定した XML を挿入し、選択した文字列を置き換えます。

構文

expression. InsertXML( _XML_ , _Transform_ )

式Selection オブジェクトを返す式。

パラメーター

名前 必須 / オプション データ型 説明
XML 必須 String 挿入する XML を指定します。 ここには有効なカスタム XML を指定できます。
Transform 省略可能 バリアント型 (Variant) XML の変換に使用する XML Transformation (XSLT) を指定します。 省略すると、変換が適用されていないカスタム XML として XML が挿入されます。

戻り値

なし

例

次の使用例は、文書のカーソル位置に指定した XML 文字列を挿入するか、または作業中の選択部分を置き換えます。

Dim strXML As String 
 
strXML = "<"xml version=""1.0""><abc:books xmlns:abc=""urn:books"" " & _ 
 "xmlns:xsi=""https://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>" 
 
Selection.InsertXML strXML

関連項目

Selection オブジェクト

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。