This documentation is archived and is not being maintained.

XPathNavigator.CanEdit Property

Gets a value indicating whether the XPathNavigator can edit the underlying XML data.

Namespace:  System.Xml.XPath
Assembly:  System.Xml (in System.Xml.dll)

public virtual bool CanEdit { get; }

Property Value

Type: System.Boolean
true if the XPathNavigator can edit the underlying XML data; otherwise false.

The CanEdit property has different values based on the three different implementations of the IXPathNavigable interface in the .NET Framework. The CanEdit values for XPathNavigator objects created by each implementation are listed in the following table.

IXPathNavigable Implementation

CanEdit Value





The following example uses the CanEdit property to display the CanEdit values of the XPathDocument and XmlDocument classes.

XPathDocument readOnlyDocument = new XPathDocument("books.xml");
XPathNavigator readOnlyNavigator = readOnlyDocument.CreateNavigator();

XmlDocument editableDocument = new XmlDocument();
XPathNavigator editableNavigator = editableDocument.CreateNavigator();

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

The example takes the books.xml file as an input.

    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
        <title>The Autobiography of Benjamin Franklin</title>
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">
        <title>The Confidence Man</title>
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">
        <title>The Gorgias</title>

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0