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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xpath filter in xmldatasource control

Status
Not open for further replies.

arst06d

Programmer
Nov 29, 2002
324
hi

I have an xml document as follows:

Code:
<?xml version="1.0" encoding="utf-8" ?>

<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>

Can someone priovide the syntax for the xpath property if I just want to show nodes where the type attribute is "Account"?

(is it just me, or is the MS help documentation pretty difficult to find anything helpful in ....?)

cheers

David
 
You would probably get a quicker response if you post this in the XML forum:

forum426

JIm
 

Hi

I thought this was a better forum as it deals specifically with asp.net and I'm using the xmldatasource server control. I'll stick with this post rather than raise a dupe (for a while, anyway ...)

Anyway, here's what I have so far
Code:
<asp:XmlDataSource 
   ID="XmlDataSource1" 
   runat="server" DataFile="~/Accounts/Accounts.xml"
   XPath="accounts/account[type] = 'Account'">
</asp:XmlDataSource>

I get an error saying the expression must evaluate to a nodeset - so obviously have it wrong!
 
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