XPathNavigator.CanEdit XPathNavigator.CanEdit XPathNavigator.CanEdit XPathNavigator.CanEdit Property

Definizione

Ottiene un valore che indica se XPathNavigator può modificare i dati XML sottostanti.Gets a value that indicates whether the XPathNavigator can edit the underlying XML data.

public:
 virtual property bool CanEdit { bool get(); };
public virtual bool CanEdit { get; }
member this.CanEdit : bool
Public Overridable ReadOnly Property CanEdit As Boolean

Valore della proprietà

trueSe può modificare i dati XML sottostanti; in caso falsecontrario,. XPathNavigatortrue if the XPathNavigator can edit the underlying XML data; otherwise, false.

Esempi

Nell'esempio seguente viene utilizzata CanEdit la proprietà per visualizzare CanEdit i valori delle XPathDocument classi XmlDocument e.The following example uses the CanEdit property to display the CanEdit values of the XPathDocument and XmlDocument classes.

      XPathDocument^ readOnlyDocument = gcnew XPathDocument("books.xml");
      XPathNavigator^ readOnlyNavigator = readOnlyDocument->CreateNavigator();

      XmlDocument^ editableDocument = gcnew XmlDocument();
      editableDocument->Load("books.xml");
      XPathNavigator^ editableNavigator = editableDocument->CreateNavigator();

Console::WriteLine("XPathNavigator.CanEdit from XPathDocument: {0}", readOnlyNavigator->CanEdit);
Console::WriteLine("XPathNavigator.CanEdit from XmlDocument: {0}", editableNavigator->CanEdit);
XPathDocument readOnlyDocument = new XPathDocument("books.xml");
XPathNavigator readOnlyNavigator = readOnlyDocument.CreateNavigator();

XmlDocument editableDocument = new XmlDocument();
editableDocument.Load("books.xml");
XPathNavigator editableNavigator = editableDocument.CreateNavigator();

Console.WriteLine("XPathNavigator.CanEdit from XPathDocument: {0}", readOnlyNavigator.CanEdit);
Console.WriteLine("XPathNavigator.CanEdit from XmlDocument: {0}", editableNavigator.CanEdit);
Dim readOnlyDocument As XPathDocument = New XPathDocument("books.xml")
Dim readOnlyNavigator As XPathNavigator = readOnlyDocument.CreateNavigator()

Dim editableDocument As XmlDocument = New XmlDocument()
editableDocument.Load("books.xml")
Dim editableNavigator As XPathNavigator = editableDocument.CreateNavigator()

Console.WriteLine("XPathNavigator.CanEdit from XPathDocument: {0}", readOnlyNavigator.CanEdit)
Console.WriteLine("XPathNavigator.CanEdit from XmlDocument: {0}", editableNavigator.CanEdit)

Nell'esempio il file books.xml viene considerato come input.The example takes the books.xml file as an input.


<?xml version="1.0" encoding="utf-8" ?>   
<bookstore>  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

Commenti

La CanEdit proprietà ha valori diversi in base alle tre diverse implementazioni IXPathNavigable dell'interfaccia nel .NET Framework.The CanEdit property has different values based on the three different implementations of the IXPathNavigable interface in the .NET Framework. I valori per XPathNavigator gli oggetti creati da ogni implementazione sono elencati nella tabella seguente. CanEditThe CanEdit values for XPathNavigator objects created by each implementation are listed in the following table.

Implementazione di IXPathNavigableIXPathNavigable Implementation Valore di CanEditCanEdit Value
XPathDocument false
XmlDocument true

Si applica a