Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XPath filter

Status
Not open for further replies.

arst06d

Programmer
Nov 29, 2002
324
Hi
I'm using an XMLDatasource control in Visual Web Developer Express 2005, which reads the following xml file:

Code:
<accounts>
  <account number="999999" type="Account" name="account name" ccy="GBP" balance="100.36" />
  <account number="888888" type="Account" name="account name2" ccy="GBP" balance="-999.36" />
  <account number="123456" type="CARD" name="Card name" ccy="GBP" balance="-258.99" />
</accounts>

Here's the xmldatasource control
Code:
       <asp:XmlDataSource 
        ID="XmlDataSource1" 
        runat="server" 
        DataFile="~/Accounts/Accounts.xml" 
        XPath="/accounts/account[@type]='Account'" >
       </asp:XmlDataSource>

as you can see I'm trying to filter the data so that only nodes with an attribute type = "Account" is returned.
I have tried various permutations but I always get "Expression must evaluate to a node".

Any help will be appreciated.

(I have posted this in the ASP.Net forum, but was told to try here .....)
 
My fault - had the ] in the wrong place

Code:
       <asp:XmlDataSource 
        ID="XmlDataSource1" 
        runat="server" 
        DataFile="~/Accounts/Accounts.xml" 
        XPath="accounts/account[@type='Account']" >
       </asp:XmlDataSource>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top