SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : XML Technologies :

Previous DiscussionNext Discussion
 XPath Query Problem

For ex: i want to get "book1" that has both categoryname='Data' and categoryname='XML'. Not just one of them. i tried following XPath queries but first one returns all the books.
The second does not return anything because @categoryname cannot be 'Data' and 'XML' at the same time.
How can i query this?

/books/book/related[@categoryname='Data' or @categoryname='XML']/..
/books/book/related[@categoryname='Data' and @categoryname='XML']/..












Started By mavilym on Aug 15, 2006 at 3:05:35 PM

7 Response(s) | Reply

Earlier Replies | Replies 1 to 7 of 7 | Later Replies
Goto Page: 1
BachusII on Aug 15, 2006 at 4:01:38 PM (# 1)

/books/book[/related/@categoryname='Data' and /related/@categoryname='XML'] ?


ARWolff on Aug 15, 2006 at 4:40:19 PM (# 2)

Could you provide a snippet of the XML you hope to query? Your first predicate looks right, if  you have a structure like

<books>
     <book cagtegoryname='XML'>...</book1>
     <book cagtegoryname='Data'>...</book1>
     <book cagtegoryname='XML'>...</book1>
     <book cagtegoryname='Cooking'>...</book1>
     <book cagtegoryname='Art History'>...</book1>

</books>


mavilym on Aug 15, 2006 at 11:30:28 PM (# 3)
This message has been edited.

sorry i sent the snippet, but it did not displayed :-(
i am sending it again. after converting tag start and elements to their HTML code.

The first query returns all the books i want just book1.

<books>
  <book name='book1'>
     <related categoryname='Data'/>
     <related categoryname='XML'/>
  </book>
  <book name='book2'>
     <related categoryname='Data'/>
  </book>
  <book name='book3'>
     <related categoryname='XML'/>
  </book>
</books>


mavilym on Aug 16, 2006 at 1:14:43 AM (# 4)

For ex: i want to get "book1" that has both categoryname='Data' and categoryname='XML'. Not just 'XML' or just 'Data'


ARWolff on Aug 16, 2006 at 3:38:52 AM (# 5)

OK. Bachusll was close.

select = "//books/book[related[@categoryname='Data'] and related[[@categoryname='XML']]"

This selects all book elements who have at least one related child with a categoryname attribute of "Data," and at least one related child with a categoryname attribute of "XML."


mavilym on Aug 16, 2006 at 5:11:00 AM (# 6)

"//books/book[related[@categoryname='Data'] and related[@categoryname='XML']]"

solved my problem. thanks.


darrellblackhawk on Apr 29, 2007 at 7:01:04 PM (# 7)

undefined


Earlier Replies | Replies 1 to 7 of 7 | Later Replies
Goto Page: 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.