Bookmark.XMLNodes Property

Definition

Gets an XMLNodes collection that represents the collection of all XML elements within a Bookmark control, including those elements that are only partially within the Bookmark control.

public:
 property Microsoft::Office::Interop::Word::XMLNodes ^ XMLNodes { Microsoft::Office::Interop::Word::XMLNodes ^ get(); };
public Microsoft.Office.Interop.Word.XMLNodes XMLNodes { get; }
member this.XMLNodes : Microsoft.Office.Interop.Word.XMLNodes
Public ReadOnly Property XMLNodes As XMLNodes

Property Value

An XMLNodes collection.

Examples

The following code example adds a Bookmark control to the document and then inserts XML text into the bookmark. A message box then displays the total number of XMLNodes and the XML content of the bookmark.

This example is for a document-level customization.

private void BookmarkInsertXML()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "Sample of bookmark text.";
    
    bookmark1.Words[1].InsertXML("<example>This is an example.</example>",
        ref missing);

    MessageBox.Show("Total XMLNodes in bookmark1: " + bookmark1.XMLNodes.Count +
        "\n" + "XML contents: " + bookmark1.XML[true]);
}
Private Sub BookmarkInsertXML()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
    Bookmark1.Text = "Sample of bookmark text."
    Bookmark1.Words(1).InsertXML( _
        "<example>This is an example.</example>")
    MessageBox.Show("Total XMLNodes in Bookmark1: " & _
        Bookmark1.XMLNodes.Count.ToString & vbLf & vbLf & _
        "XML contents: " & Bookmark1.XML(True))

End Sub

Applies to