Bookmark.XML Property (2007 System)

Gets the XML text in the Bookmark control.

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property XML As Bookmark._XMLType
'Usage
Dim instance As Bookmark 
Dim value As Bookmark._XMLType 

value = instance.XML
[BrowsableAttribute(false)]
public Bookmark._XMLType XML { get; }
[BrowsableAttribute(false)]
public:
property Bookmark._XMLType^ XML {
    Bookmark._XMLType^ get ();
}
public function get XML () : Bookmark._XMLType

Property Value

Type: Microsoft.Office.Tools.Word.Bookmark._XMLType
The XML text in the Bookmark control.

Remarks

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 attempt to use XML without specifying a parameter, XML will get a Bookmark._XMLType object that is part of the Visual Studio Tools for Office infrastructure and is not intended to be used directly from your code.

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 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
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]);
}

.NET Framework Security

See Also

Reference

Bookmark Class

Bookmark Members

Microsoft.Office.Tools.Word Namespace