Mega Code Archive

 
Categories / C# / XML
 

XPathNavigator CanEdit indicates whether the XPathNavigator can edit the underlying XML data

using System; using System.Linq; using System.Xml; using System.Xml.XPath; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass {     public static void Main()     {         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);     } } /* <?xml version="1.0" encoding="utf-8" ?>  <bookstore>     <book genre="Programming" publicationdate="2010-03-22" ISBN="1-111111-11-0">         <title>C#</title>         <author>             <first-name>A</first-name>             <last-name>B</last-name>         </author>         <price>8.99</price>     </book>     <book genre="data" publicationdate="2010-11-17" ISBN="0-201-11111-2">         <title>XML</title>         <author>             <first-name>D</first-name>             <last-name>E</last-name>         </author>         <price>11.99</price>     </book> </bookstore> */