394 Chapter 8 • Using XML in the .NET Framework
To search for a particular value of an element (e.g., of an account holder’s name), we have used the following expression:
descendant::Account[child::Name='"+accName+"']/Balance
We needed to call the MoveNext method of the Iterator object in order to get to the balance node.The following expression illustrates the construct:
Bank/Account[@AccountNo='"+accNo+"']/Balance
Figure 8.39 Complete Code XPathDoc2.aspx
<!— Chapter8/XPathDoc2.aspx —>
<%@ Page Language="VB" Debug="True"%> <%@ Import Namespace="System.Xml"%>
<%@ Import Namespace="System.Xml.XPath"%> <%@ Import Namespace="System.Xml.Xsl"%> <html><head></head><body>
<form runat="server"><h4> Balance Inquiry Screen</h4> Select an Account Number:
<asp:DropdownList id="cboAcno" runat="server" width="100" /> <br/><br/>
Balance from Account Number Search:
<asp:Textbox id="txtBalance1" runat="server" width="80" /> <br/><br/><hr/>
Select an Customer Name:
<asp:DropdownList id="cboName" runat="server" width="110" /> <br/><br/>
Balance from Customer Name Search :
<asp:Textbox id="txtBalance2" runat="server" width="80" /> <br/><br/>
<asp:Button id="cmdDetails" Text="Show Balances" runat="server" onClick="showNames"/><br/>
</form></body></html>
<Script Language="vb" runat="server">
Continued