Condividi tramite


Proprietà DocumentBase.XMLNodes

Ottiene un insieme di Microsoft.Office.Interop.Word.XMLNodes che rappresenta tutti gli elementi XML presenti nel documento.

Spazio dei nomi:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Sintassi

'Dichiarazione
Public ReadOnly Property XMLNodes As XMLNodes
    Get
public XMLNodes XMLNodes { get; }

Valore proprietà

Tipo: Microsoft.Office.Interop.Word.XMLNodes
Insieme di Microsoft.Office.Interop.Word.XMLNodes che rappresenta tutti gli elementi XML presenti nel documento.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato come visualizzare i nomi degli oggetti Microsoft.Office.Interop.Word.XMLNodes nel documento. Per utilizzare questo esempio, eseguirlo dalla classe ThisDocument in un progetto a livello di documento.

Private Sub DocumentXMLNodes()
    Dim stringBuilder1 As New System.Text.StringBuilder()

    ' Add all of the node names to the StringBuilder.
    Dim node As Word.XMLNode
    For Each node In Me.XMLNodes
        stringBuilder1.Append(node.BaseName & ", ")
    Next node

    ' End the StringBuilder with a period.
    stringBuilder1.Remove(stringBuilder1.Length - 2, 2)
    stringBuilder1.Append(".")

    MessageBox.Show("The document contains " & Me.XMLNodes.Count.ToString() _
        & " node(s): " & stringBuilder1.ToString())
End Sub 
private void DocumentXMLNodes()
{
    System.Text.StringBuilder stringBuilder1 =
        new System.Text.StringBuilder();

    // Add all of the node names to the StringBuilder.
    foreach (Word.XMLNode node in this.XMLNodes)
    {
        stringBuilder1.Append(node.BaseName + ", ");
    }

    // End the StringBuilder with a period.
    stringBuilder1.Remove(stringBuilder1.Length - 2, 2);
    stringBuilder1.Append(".");

    MessageBox.Show("The document contains " +
        this.XMLNodes.Count.ToString() + " node(s): " +
        stringBuilder1.ToString());
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

DocumentBase Classe

Spazio dei nomi Microsoft.Office.Tools.Word