DocumentBase.WordOpenXML Property

Gets an XML string that contains the contents of the document in the Word Open XML format.

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

Syntax

'Declaration
Public ReadOnly Property WordOpenXML As String
    Get
public string WordOpenXML { get; }

Property Value

Type: System.String
An XML string that contains the contents of the document in the Word Open XML format.

Examples

The following code example retrieves the Open XML content of the current document and saves this XML content into a file in the current directory. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub GetXMLContent()
    ' Get XML content
    Dim XMLContent As String = Me.WordOpenXML
    ' Save XML content into a file in the current directory
    Dim sw As System.IO.StreamWriter = _
        System.IO.File.CreateText("myXMLDoc.xml")
    sw.Write(XMLContent)
    sw.Close()
End Sub
private void GetXMLContent()
{            
    // Get XML content
    string XMLContent = this.WordOpenXML;
    // Save XML content into a file in the current directory
    System.IO.StreamWriter sw = 
        System.IO.File.CreateText(@"myXMLDoc.xml");
    sw.Write(XMLContent);
    sw.Close();
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace