Csharp/C Sharp by API/System.Xml.XPath/XPathNodeType — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 15:11, 26 мая 2010
XPathNodeType.Element
<source lang="csharp"> using System; using System.Collections.Generic; using System.Data; using System.Text; using System.Xml; using System.Xml.XPath; public class MainClass {
public static void Main() { XPathDocument doc = new XPathDocument("books.xml"); XPathNavigator nav = ((IXPathNavigable)doc).CreateNavigator(); XPathNodeIterator iter = nav.Select("/bookstore/book[@genre="novel"]"); while (iter.MoveNext()) { XPathNodeIterator newIter = iter.Current.SelectDescendants(XPathNodeType.Element, false); while (newIter.MoveNext()) Console.WriteLine(newIter.Current.Name + ": " + newIter.Current.Value); } }
}
</source>