XPathnavigator (1) of System.xml.xpath

xiaoxiao2021-03-06  70

The XPathnavigator class is a subclass in the XPathDocumNet. DotNetfx V1, V2 has. XpathDocument has many new classes and methods in V2, more powerful, and xQuery, so you can get the same part and V1 version. static void Main (string [] args) {// xpath object load xml file XPathDocument xpDoc = new XPathDocument ( "booksort.xml"); // create a XPathNavigator object XPathNavigator xpNav = xpDoc.CreateNavigator (); // XPathExpression integrated XPath expression, if you need to sort / * xpaxpression xpexpr = xpnav.compile ("Descendant :: Book [Author / Last-name = 'Austen'); XPEXPR.Addsort (" Title ", XmlsortOrder.Descending, XmlcaseOrder. None, "" "" "" "" "" "" "" "" "" "xpnodeiterator xpni = xpnav.select (xpexpr); * // does not need to be sorted, directly put the node of XPath query into an XPathNodeEiterator node XpathodeEiterator xpni = xpnav.select (" Descendant :: Book [Author / Last-Name = 'AUSTEN'] "); // Operation XpathnodeEiterator While (xpni.movenext ()) {// The best use of Clone method to make an easy operation // xpathnavigator clone = xpni.current. Clone (); //clone.movetofirstchild (); //Console.writeline ("{0}: {1}", clone.name, clone.value; xpni.current.movetofirstchild (); console.writeline ("{0}, {1}", xpni.current .Name, xpni.current.value; console.readline ();}} This is passed in V1, V2, both of which have the above properties and methods.

转载请注明原文地址:https://www.9cbs.com/read-109607.html

New Post(0)