XPathDocument doc = new XPathDocument(Server.MapPath("Demo.xml"));
XPathNavigator nav = doc.CreateNavigator();
XPathExpression xpathExpress = nav.Compile("//bk:Book[position()"
+this.ddownlist.SelectedValue.Trim()+this.txtNum.Text.Trim()+"]");
//use AddNamespace
XmlNamespaceManager xmlManager = new XmlNamespaceManager(nav.NameTable);
xmlManager.AddNamespace("bk", "http://myserver/myschemas/Books");
xpathExpress.SetContext(xmlManager);
XPathNodeIterator xIterator = nav.Select(xpathExpress);
this.TextBox1.Text = "";
this.TextBox1.ForeColor = System.Drawing.Color.Empty;
while (xIterator.MoveNext())
this.TextBox1.Text = this.TextBox1.Text + "\r\n" + xIterator.Current.Value;
if (xIterator.Count.Equals(0))
{
this.TextBox1.Text = "There is no xml data in the condition.";
this.TextBox1.ForeColor = System.Drawing.Color.Red;
}
xmlManager = null;
nav = null;
doc = null;