This documentation is archived and is not being maintained.

Bookmark.XML Property

 

Gets the XML text in the Bookmark control.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Bookmark_XMLType XML { get; }

Property Value

Type: Microsoft.Office.Tools.Word.Bookmark_XMLType

The XML text in the Bookmark control.

The XML property is intended to be used with the following parameter.

Parameter

Description

DataOnly

true to return the text of the XML without the Word XML markup; otherwise, false.

If you use the XML property without specifying a parameter, it returns a Bookmark_XMLType object that is not intended to be used directly from your code.

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]);
}
Return to top
Show: