<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FXML%2FXPath</id>
		<title>Csharp/C Sharp/XML/XPath - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FXML%2FXPath"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/XML/XPath&amp;action=history"/>
		<updated>2026-04-29T16:38:12Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/XML/XPath&amp;diff=296&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/XML/XPath&amp;diff=296&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Find Elements with an XPath Search==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Xml;&lt;br /&gt;
public class XPathSelectNodes {&lt;br /&gt;
    private static void Main() {&lt;br /&gt;
        // Load the document.&lt;br /&gt;
        XmlDocument doc = new XmlDocument();&lt;br /&gt;
        doc.Load(&amp;quot;books.xml&amp;quot;);&lt;br /&gt;
        XmlNodeList nodes = doc.SelectNodes(&amp;quot;/books/A/B&amp;quot;);&lt;br /&gt;
            &lt;br /&gt;
        foreach (XmlNode node in nodes) {&lt;br /&gt;
            Console.WriteLine(node.InnerText);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
&amp;lt;books&amp;gt;&lt;br /&gt;
  &amp;lt;A property=&amp;quot;a&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;B&amp;gt;text&amp;lt;/B&amp;gt;&lt;br /&gt;
    &amp;lt;C&amp;gt;textg&amp;lt;/C&amp;gt;&lt;br /&gt;
    &amp;lt;D&amp;gt;99999&amp;lt;/D&amp;gt;&lt;br /&gt;
  &amp;lt;/A&amp;gt;&lt;br /&gt;
&amp;lt;/books&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Read XML node using the XML path==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Xml;&lt;br /&gt;
public class SellItems {&lt;br /&gt;
  &lt;br /&gt;
  static void Main(string [] args) {&lt;br /&gt;
    XmlDocument inventory = new XmlDocument();&lt;br /&gt;
    inventory.Load(&amp;quot;inventory.xml&amp;quot;);&lt;br /&gt;
    XmlNodeList elements = inventory.SelectNodes(&amp;quot;//inventory/items/item&amp;quot;);&lt;br /&gt;
    foreach (XmlElement element in elements) {&lt;br /&gt;
        string productCode = element.GetAttribute(&amp;quot;productCode&amp;quot;);&lt;br /&gt;
        int quantitySold = Int32.Parse(element.GetAttribute(&amp;quot;quantity&amp;quot;));&lt;br /&gt;
        Console.WriteLine(quantitySold);&lt;br /&gt;
        &lt;br /&gt;
        string xPathExpression = &amp;quot;//items/item[@productCode=&amp;quot;&amp;quot; + productCode + &amp;quot;&amp;quot;]&amp;quot;;&lt;br /&gt;
        XmlElement inventoryItem = (XmlElement)inventory.SelectSingleNode(xPathExpression);&lt;br /&gt;
    &lt;br /&gt;
        int quantity = Int32.Parse(inventoryItem.GetAttribute(&amp;quot;quantity&amp;quot;));&lt;br /&gt;
        quantity -= quantitySold;&lt;br /&gt;
        inventoryItem.SetAttribute(&amp;quot;quantity&amp;quot;,quantity.ToString());&lt;br /&gt;
    }&lt;br /&gt;
    inventory.Save(&amp;quot;inventory.xml&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
&amp;lt;inventory&amp;gt;&lt;br /&gt;
  &amp;lt;date year=&amp;quot;2006&amp;quot; month=&amp;quot;8&amp;quot; day=&amp;quot;27&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;items&amp;gt;&lt;br /&gt;
    &amp;lt;item quantity=&amp;quot;5&amp;quot; productCode=&amp;quot;01&amp;quot; description=&amp;quot;PHP&amp;quot;  unitCost=&amp;quot;9.95&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;item quantity=&amp;quot;3&amp;quot; productCode=&amp;quot;02&amp;quot; description=&amp;quot;Perl&amp;quot; unitCost=&amp;quot;4.95&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/items&amp;gt;&lt;br /&gt;
&amp;lt;/inventory&amp;gt;&lt;br /&gt;
*/&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Select by path==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Xml;&lt;br /&gt;
using System.Xml.XPath;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        XmlDocument doc = new XmlDocument();&lt;br /&gt;
        doc.Load(&amp;quot;books.xml&amp;quot;);&lt;br /&gt;
        XPathNavigator nav = doc.CreateNavigator();&lt;br /&gt;
        if (nav.CanEdit) {&lt;br /&gt;
            XPathNodeIterator iter = nav.Select(&amp;quot;/bookstore/book/price&amp;quot;);&lt;br /&gt;
            while (iter.MoveNext()) {&lt;br /&gt;
                iter.Current.InsertAfter(&amp;quot;&amp;lt;disc&amp;gt;5&amp;lt;/disc&amp;gt;&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        doc.Save(&amp;quot;newbooks.xml&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}  &lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==XmlQuery Example==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Xml;&lt;br /&gt;
class Form1 : Form {&lt;br /&gt;
    private XmlDocument mDocument;&lt;br /&gt;
    private XmlNode mCurrentNode;&lt;br /&gt;
    public Form1() {&lt;br /&gt;
        InitializeComponent();&lt;br /&gt;
        mDocument = new XmlDocument();&lt;br /&gt;
        mDocument.Load(&amp;quot;XPathQuery.xml&amp;quot;);&lt;br /&gt;
        mCurrentNode = mDocument.DocumentElement;&lt;br /&gt;
        ClearListBox();&lt;br /&gt;
    }&lt;br /&gt;
    private void DisplayList(XmlNodeList nodeList) {&lt;br /&gt;
        foreach (XmlNode node in nodeList) {&lt;br /&gt;
            RecurseXmlDocumentNoSiblings(node, 0);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void RecurseXmlDocumentNoSiblings(XmlNode root, int indent) {&lt;br /&gt;
        if (root == null)&lt;br /&gt;
            return;&lt;br /&gt;
        if (root is XmlElement) {&lt;br /&gt;
            listBoxResult.Items.Add(root.Name.PadLeft(root.Name.Length + indent));&lt;br /&gt;
            if (root.HasChildNodes)&lt;br /&gt;
                RecurseXmlDocument(root.FirstChild, indent + 2);&lt;br /&gt;
        } else if (root is XmlText) {&lt;br /&gt;
            string text = ((XmlText)root).Value;&lt;br /&gt;
            listBoxResult.Items.Add(text.PadLeft(text.Length + indent));&lt;br /&gt;
        } else if (root is XmlComment) {&lt;br /&gt;
            string text = root.Value;&lt;br /&gt;
            listBoxResult.Items.Add(text.PadLeft(text.Length + indent));&lt;br /&gt;
            if (root.HasChildNodes)&lt;br /&gt;
                RecurseXmlDocument(root.FirstChild, indent + 2);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void RecurseXmlDocument(XmlNode root, int indent) {&lt;br /&gt;
        if (root == null)&lt;br /&gt;
            return;&lt;br /&gt;
        if (root is XmlElement) {&lt;br /&gt;
            listBoxResult.Items.Add(root.Name.PadLeft(root.Name.Length + indent));&lt;br /&gt;
            if (root.HasChildNodes)&lt;br /&gt;
                RecurseXmlDocument(root.FirstChild, indent + 2);&lt;br /&gt;
            if (root.NextSibling != null)&lt;br /&gt;
                RecurseXmlDocument(root.NextSibling, indent);&lt;br /&gt;
        } else if (root is XmlText) {&lt;br /&gt;
            string text = ((XmlText)root).Value;&lt;br /&gt;
            listBoxResult.Items.Add(text.PadLeft(text.Length + indent));&lt;br /&gt;
        } else if (root is XmlComment) {&lt;br /&gt;
            string text = root.Value;&lt;br /&gt;
            listBoxResult.Items.Add(text.PadLeft(text.Length + indent));&lt;br /&gt;
            if (root.HasChildNodes)&lt;br /&gt;
                RecurseXmlDocument(root.FirstChild, indent + 2);&lt;br /&gt;
            if (root.NextSibling != null)&lt;br /&gt;
                RecurseXmlDocument(root.NextSibling, indent);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void ClearListBox() {&lt;br /&gt;
        listBoxResult.Items.Clear();&lt;br /&gt;
    }&lt;br /&gt;
    private void radioButtonSelectRoot_CheckedChanged(object sender, EventArgs e) {&lt;br /&gt;
        mCurrentNode = mCurrentNode.SelectSingleNode(&amp;quot;//books&amp;quot;);&lt;br /&gt;
        ClearListBox();&lt;br /&gt;
        RecurseXmlDocument(mCurrentNode, 0);&lt;br /&gt;
    }&lt;br /&gt;
    private void buttonClose_Click(object sender, EventArgs e) {&lt;br /&gt;
        Application.Exit();&lt;br /&gt;
    }&lt;br /&gt;
    private void buttonExecute_Click(object sender, EventArgs e) {&lt;br /&gt;
        if (textBoxQuery.Text == &amp;quot;&amp;quot;)&lt;br /&gt;
            return;&lt;br /&gt;
        try {&lt;br /&gt;
            XmlNodeList nodeList = mCurrentNode.SelectNodes(textBoxQuery.Text);&lt;br /&gt;
            ClearListBox();&lt;br /&gt;
            DisplayList(nodeList);&lt;br /&gt;
        } catch (System.Exception err) {&lt;br /&gt;
            MessageBox.Show(err.Message);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void radioButtonSelectAllAuthors_CheckedChanged(object sender, EventArgs e) {&lt;br /&gt;
        XmlNodeList nodeList = mCurrentNode.SelectNodes(&amp;quot;//book/author&amp;quot;);&lt;br /&gt;
        ClearListBox();&lt;br /&gt;
        DisplayList(nodeList);&lt;br /&gt;
    }&lt;br /&gt;
    private void radioButtonSelectSpecificAuthor_CheckedChanged(object sender, EventArgs e) {&lt;br /&gt;
        XmlNodeList nodeList = mCurrentNode.SelectNodes(&amp;quot;//book[author=&amp;quot;J&amp;quot;]&amp;quot;);&lt;br /&gt;
        ClearListBox();&lt;br /&gt;
        DisplayList(nodeList);&lt;br /&gt;
    }&lt;br /&gt;
    private void radioButtonSelectAllBooks_CheckedChanged(object sender, EventArgs e) {&lt;br /&gt;
        XmlNodeList nodeList = mCurrentNode.SelectNodes(&amp;quot;//book&amp;quot;);&lt;br /&gt;
        ClearListBox();&lt;br /&gt;
        DisplayList(nodeList);&lt;br /&gt;
    }&lt;br /&gt;
    private void radioButtonSetBookAsCurrent_CheckedChanged(object sender, EventArgs e) {&lt;br /&gt;
        mCurrentNode = mCurrentNode.SelectSingleNode(&amp;quot;book[title=&amp;quot;C#&amp;quot;]&amp;quot;);&lt;br /&gt;
        ClearListBox();&lt;br /&gt;
        RecurseXmlDocumentNoSiblings(mCurrentNode, 0);&lt;br /&gt;
    }&lt;br /&gt;
    private void radioButtonSetBooksAsCurrent_CheckedChanged(object sender, EventArgs e) {&lt;br /&gt;
        mCurrentNode = mCurrentNode.SelectSingleNode(&amp;quot;//books&amp;quot;);&lt;br /&gt;
        ClearListBox();&lt;br /&gt;
        RecurseXmlDocumentNoSiblings(mCurrentNode, 0);&lt;br /&gt;
    }&lt;br /&gt;
    private void radioButtonSelectAllChildren_CheckedChanged(object sender, EventArgs e) {&lt;br /&gt;
        XmlNodeList nodeList = mCurrentNode.SelectNodes(&amp;quot;*&amp;quot;);&lt;br /&gt;
        ClearListBox();&lt;br /&gt;
        DisplayList(nodeList);&lt;br /&gt;
    }&lt;br /&gt;
    private void InitializeComponent() {&lt;br /&gt;
        this.radioButtonSelectRoot = new System.Windows.Forms.RadioButton();&lt;br /&gt;
        this.radioButtonSelectAllChildren = new System.Windows.Forms.RadioButton();&lt;br /&gt;
        this.radioButtonSetBooksAsCurrent = new System.Windows.Forms.RadioButton();&lt;br /&gt;
        this.radioButtonSetBookAsCurrent = new System.Windows.Forms.RadioButton();&lt;br /&gt;
        this.radioButtonSelectAllBooks = new System.Windows.Forms.RadioButton();&lt;br /&gt;
        this.radioButtonSelectSpecificAuthor = new System.Windows.Forms.RadioButton();&lt;br /&gt;
        this.radioButtonSelectAllAuthors = new System.Windows.Forms.RadioButton();&lt;br /&gt;
        this.textBoxQuery = new System.Windows.Forms.TextBox();&lt;br /&gt;
        this.buttonExecute = new System.Windows.Forms.Button();&lt;br /&gt;
        this.buttonClose = new System.Windows.Forms.Button();&lt;br /&gt;
        this.listBoxResult = new System.Windows.Forms.ListBox();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        this.radioButtonSelectRoot.AutoSize = true;&lt;br /&gt;
        this.radioButtonSelectRoot.Location = new System.Drawing.Point(13, 234);&lt;br /&gt;
        this.radioButtonSelectRoot.Size = new System.Drawing.Size(72, 17);&lt;br /&gt;
        this.radioButtonSelectRoot.Text = &amp;quot;Select root&amp;quot;;&lt;br /&gt;
        this.radioButtonSelectRoot.CheckedChanged += new System.EventHandler(this.radioButtonSelectRoot_CheckedChanged);&lt;br /&gt;
        this.radioButtonSelectAllChildren.AutoSize = true;&lt;br /&gt;
        this.radioButtonSelectAllChildren.Location = new System.Drawing.Point(163, 282);&lt;br /&gt;
        this.radioButtonSelectAllChildren.Size = new System.Drawing.Size(104, 17);&lt;br /&gt;
        this.radioButtonSelectAllChildren.Text = &amp;quot;Select all children&amp;quot;;&lt;br /&gt;
        this.radioButtonSelectAllChildren.CheckedChanged += new System.EventHandler(this.radioButtonSelectAllChildren_CheckedChanged);&lt;br /&gt;
        this.radioButtonSetBooksAsCurrent.AutoSize = true;&lt;br /&gt;
        this.radioButtonSetBooksAsCurrent.Location = new System.Drawing.Point(163, 258);&lt;br /&gt;
        this.radioButtonSetBooksAsCurrent.Size = new System.Drawing.Size(120, 17);&lt;br /&gt;
        this.radioButtonSetBooksAsCurrent.Text = &amp;quot;Set Books as current&amp;quot;;&lt;br /&gt;
        this.radioButtonSetBooksAsCurrent.CheckedChanged += new System.EventHandler(this.radioButtonSetBooksAsCurrent_CheckedChanged);&lt;br /&gt;
        this.radioButtonSetBookAsCurrent.AutoSize = true;&lt;br /&gt;
        this.radioButtonSetBookAsCurrent.Location = new System.Drawing.Point(163, 234);&lt;br /&gt;
        this.radioButtonSetBookAsCurrent.Size = new System.Drawing.Size(115, 17);&lt;br /&gt;
        this.radioButtonSetBookAsCurrent.Text = &amp;quot;Set Book as current&amp;quot;;&lt;br /&gt;
        this.radioButtonSetBookAsCurrent.CheckedChanged += new System.EventHandler(this.radioButtonSetBookAsCurrent_CheckedChanged);&lt;br /&gt;
        this.radioButtonSelectAllBooks.AutoSize = true;&lt;br /&gt;
        this.radioButtonSelectAllBooks.Location = new System.Drawing.Point(13, 306);&lt;br /&gt;
        this.radioButtonSelectAllBooks.Size = new System.Drawing.Size(96, 17);&lt;br /&gt;
        this.radioButtonSelectAllBooks.Text = &amp;quot;Select all books&amp;quot;;&lt;br /&gt;
        this.radioButtonSelectAllBooks.CheckedChanged += new System.EventHandler(this.radioButtonSelectAllBooks_CheckedChanged);&lt;br /&gt;
        this.radioButtonSelectSpecificAuthor.AutoSize = true;&lt;br /&gt;
        this.radioButtonSelectSpecificAuthor.Location = new System.Drawing.Point(13, 282);&lt;br /&gt;
        this.radioButtonSelectSpecificAuthor.Size = new System.Drawing.Size(137, 17);&lt;br /&gt;
        this.radioButtonSelectSpecificAuthor.Text = &amp;quot;Select by specific author&amp;quot;;&lt;br /&gt;
        this.radioButtonSelectSpecificAuthor.CheckedChanged += new System.EventHandler(this.radioButtonSelectSpecificAuthor_CheckedChanged);&lt;br /&gt;
        this.radioButtonSelectAllAuthors.AutoSize = true;&lt;br /&gt;
        this.radioButtonSelectAllAuthors.Location = new System.Drawing.Point(13, 258);&lt;br /&gt;
        this.radioButtonSelectAllAuthors.Margin = new System.Windows.Forms.Padding(3, 1, 3, 3);&lt;br /&gt;
        this.radioButtonSelectAllAuthors.Size = new System.Drawing.Size(102, 17);&lt;br /&gt;
        this.radioButtonSelectAllAuthors.Text = &amp;quot;Select all authors&amp;quot;;&lt;br /&gt;
        this.radioButtonSelectAllAuthors.CheckedChanged += new System.EventHandler(this.radioButtonSelectAllAuthors_CheckedChanged);&lt;br /&gt;
        this.textBoxQuery.Location = new System.Drawing.Point(13, 330);&lt;br /&gt;
        this.textBoxQuery.Size = new System.Drawing.Size(385, 20);&lt;br /&gt;
        this.buttonExecute.Location = new System.Drawing.Point(323, 234);&lt;br /&gt;
        this.buttonExecute.Text = &amp;quot;Execute&amp;quot;;&lt;br /&gt;
        this.buttonExecute.Click += new System.EventHandler(this.buttonExecute_Click);&lt;br /&gt;
        this.buttonClose.Location = new System.Drawing.Point(405, 13);&lt;br /&gt;
        this.buttonClose.Text = &amp;quot;Close&amp;quot;;&lt;br /&gt;
        this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);&lt;br /&gt;
        this.listBoxResult.FormattingEnabled = true;&lt;br /&gt;
        this.listBoxResult.Location = new System.Drawing.Point(13, 13);&lt;br /&gt;
        this.listBoxResult.Size = new System.Drawing.Size(385, 212);&lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(492, 362);&lt;br /&gt;
        this.Controls.Add(this.listBoxResult);&lt;br /&gt;
        this.Controls.Add(this.buttonClose);&lt;br /&gt;
        this.Controls.Add(this.buttonExecute);&lt;br /&gt;
        this.Controls.Add(this.textBoxQuery);&lt;br /&gt;
        this.Controls.Add(this.radioButtonSelectAllAuthors);&lt;br /&gt;
        this.Controls.Add(this.radioButtonSelectSpecificAuthor);&lt;br /&gt;
        this.Controls.Add(this.radioButtonSelectAllBooks);&lt;br /&gt;
        this.Controls.Add(this.radioButtonSetBookAsCurrent);&lt;br /&gt;
        this.Controls.Add(this.radioButtonSetBooksAsCurrent);&lt;br /&gt;
        this.Controls.Add(this.radioButtonSelectAllChildren);&lt;br /&gt;
        this.Controls.Add(this.radioButtonSelectRoot);&lt;br /&gt;
        this.Text = &amp;quot;XPath Queries&amp;quot;;&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
        this.PerformLayout();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    private System.Windows.Forms.RadioButton radioButtonSelectRoot;&lt;br /&gt;
    private System.Windows.Forms.RadioButton radioButtonSelectAllChildren;&lt;br /&gt;
    private System.Windows.Forms.RadioButton radioButtonSetBooksAsCurrent;&lt;br /&gt;
    private System.Windows.Forms.RadioButton radioButtonSetBookAsCurrent;&lt;br /&gt;
    private System.Windows.Forms.RadioButton radioButtonSelectAllBooks;&lt;br /&gt;
    private System.Windows.Forms.RadioButton radioButtonSelectSpecificAuthor;&lt;br /&gt;
    private System.Windows.Forms.RadioButton radioButtonSelectAllAuthors;&lt;br /&gt;
    private System.Windows.Forms.TextBox textBoxQuery;&lt;br /&gt;
    private System.Windows.Forms.Button buttonExecute;&lt;br /&gt;
    private System.Windows.Forms.Button buttonClose;&lt;br /&gt;
    private System.Windows.Forms.ListBox listBoxResult;&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Application.EnableVisualStyles();&lt;br /&gt;
        Application.Run(new Form1());&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== XPath Expression Syntax==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
Expression   Description&lt;br /&gt;
/            Starts an absolute path that selects from the root node.&lt;br /&gt;
             /Order/Items/Item selects all Item elements that are children of an Items element, &lt;br /&gt;
             which is itself a child of the root Order element.&lt;br /&gt;
//           Starts a relative path that selects nodes anywhere.&lt;br /&gt;
             //Item/Name selects all the Name elements that are children of an Item element, &lt;br /&gt;
             regardless of where they appear in the document.&lt;br /&gt;
@            Selects an attribute of a node.&lt;br /&gt;
             /Order/@id selects the attribute named id from the root Order element.&lt;br /&gt;
*            Selects any element in the path.&lt;br /&gt;
             /Order/* selects both Items and Client nodes because both are contained by a root &lt;br /&gt;
             Order element.&lt;br /&gt;
|            Combines multiple paths.&lt;br /&gt;
             &lt;br /&gt;
             /Order/Items/Item/Name|Order/Client/Name selects the Name nodes used to describe &lt;br /&gt;
             a Client and the Name nodes used to describe an Item.&lt;br /&gt;
.            Indicates the current (default) node.&lt;br /&gt;
             If the current node is an Order, the expression ./Items refers to the related &lt;br /&gt;
             items for that order.&lt;br /&gt;
..           Indicates the parent node.&lt;br /&gt;
             //Name/.. selects any element that is parent to a Name, which includes the Client &lt;br /&gt;
             and Item elements.&lt;br /&gt;
[ ]          Define selection criteria that can test a contained node or attribute value.&lt;br /&gt;
             /Order[@id=&amp;quot;1999-01-30.195496&amp;quot;] selects the Order elements with the indicated &lt;br /&gt;
             attribute value.&lt;br /&gt;
             /Order/Items/Item[Price &amp;gt; 50] selects products above $50 in price.&lt;br /&gt;
             /Order/Items/Item[Price &amp;gt; 50 and Name=&amp;quot;Laser Printer&amp;quot;] selects products that match &lt;br /&gt;
             two criteria.&lt;br /&gt;
starts-with  This function retrieves elements based on what text a contained element starts with.&lt;br /&gt;
             /Order/Items/Item[starts-with(Name, &amp;quot;C&amp;quot;)] finds all Item elements that have a &lt;br /&gt;
             Name element that starts with the letter C.&lt;br /&gt;
position     This function retrieves elements based on position.&lt;br /&gt;
             /Order/Items/Item[position ()=2] selects the second Item element.&lt;br /&gt;
count        This function counts elements. You specify the name of the child element to count or &lt;br /&gt;
             an asterisk (*) for all children.&lt;br /&gt;
             /Order/Items/Item[count(Price) = 1] retrieves Item elements that have exactly one &lt;br /&gt;
             nested Price element.&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==XPathNavigator==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Xml;&lt;br /&gt;
using System.Xml.XPath;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        XPathDocument doc = new XPathDocument(&amp;quot;books.xml&amp;quot;);&lt;br /&gt;
        XPathNavigator nav = ((IXPathNavigable)doc).CreateNavigator();&lt;br /&gt;
        XPathNodeIterator iter = nav.Select(&amp;quot;/bookstore/book[@genre=&amp;quot;novel&amp;quot;]&amp;quot;);&lt;br /&gt;
        while (iter.MoveNext()) {&lt;br /&gt;
            XPathNodeIterator newIter = iter.Current.SelectDescendants(XPathNodeType.Element, false);&lt;br /&gt;
            while (newIter.MoveNext())&lt;br /&gt;
                Console.WriteLine(newIter.Current.Name + &amp;quot;: &amp;quot; + newIter.Current.Value);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==XPathNodeIterator==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Xml;&lt;br /&gt;
using System.Xml.XPath;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        XPathDocument doc = new XPathDocument(&amp;quot;books.xml&amp;quot;);&lt;br /&gt;
        XPathNavigator nav = ((IXPathNavigable)doc).CreateNavigator();&lt;br /&gt;
        XPathNodeIterator iter = nav.Select(&amp;quot;/bookstore/book&amp;quot;);&lt;br /&gt;
        while (iter.MoveNext()) {&lt;br /&gt;
            XPathNodeIterator newIter = iter.Current.SelectDescendants(XPathNodeType.Element, false);&lt;br /&gt;
            while (newIter.MoveNext())&lt;br /&gt;
                Console.WriteLine(newIter.Current.Name + &amp;quot;: &amp;quot; + newIter.Current.Value);&lt;br /&gt;
        }&lt;br /&gt;
        Console.WriteLine(&amp;quot;Total Cost = &amp;quot; + nav.Evaluate(&amp;quot;sum(/bookstore/book/price)&amp;quot;));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==XPath Query Demo==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Xml;&lt;br /&gt;
using System.Xml.XPath;&lt;br /&gt;
public class XPathQuery {&lt;br /&gt;
  public static void Main(string [] args) {&lt;br /&gt;
    string filename = &amp;quot;inventory.xml&amp;quot;;&lt;br /&gt;
    string xpathExpression = &amp;quot;//inventory/items&amp;quot;;&lt;br /&gt;
    XmlDocument document = new XmlDocument( );&lt;br /&gt;
    document.Load(filename);&lt;br /&gt;
    XmlTextWriter writer = new XmlTextWriter(Console.Out);&lt;br /&gt;
    writer.Formatting = Formatting.Indented;&lt;br /&gt;
    XmlNode node = document.SelectSingleNode(xpathExpression);&lt;br /&gt;
    node.WriteTo(writer);&lt;br /&gt;
    writer.Close( );&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
&amp;lt;inventory&amp;gt;&lt;br /&gt;
  &amp;lt;date year=&amp;quot;2006&amp;quot; month=&amp;quot;8&amp;quot; day=&amp;quot;27&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;items&amp;gt;&lt;br /&gt;
    &amp;lt;item quantity=&amp;quot;5&amp;quot; productCode=&amp;quot;01&amp;quot; description=&amp;quot;PHP&amp;quot;  unitCost=&amp;quot;9.95&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;item quantity=&amp;quot;3&amp;quot; productCode=&amp;quot;02&amp;quot; description=&amp;quot;Perl&amp;quot; unitCost=&amp;quot;4.95&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/items&amp;gt;&lt;br /&gt;
&amp;lt;/inventory&amp;gt;&lt;br /&gt;
*/&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>