Wrox Programmer Forums
|
BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2
This is the forum to discuss the Wrox book Beginning XML, 4th Edition by David Hunter, Jeff Rafter, Joe Fawcett, Eric van der Vlist, Danny Ayers, Jon Duckett, Andrew Watt, Linda McKinnon; ISBN: 9780470114872
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 13th, 2010, 05:47 PM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Default How to get single result

Hi All,

This is my xml :

Code:
 
<?xml version="1.0" encoding="UTF-8"?>
<cheesEaters>
<person name="John"/>
<person name="charlie"/>
<person name="Lee"/>
<cheese name="Camembert"/>
<cheese name="Brie"/>
<liking person="John" cheese="Camembert"/>
<liking person="John" cheese="Brie"/>
<liking person="Lee" cheese="Brie"/>
</cheesEaters>
I want to write XQuery which will return only a pair of people based on there similar liking of chees. In the above case it shuld return 'John' and 'Lee'.

Below is my XQuery but I am not getting the desired result, could you please help to get the right result.

XQuery:

Code:
let $doc := doc('CheeseEaters.xml')
for $vper in $doc//person
for $xchz in $doc//cheese
for $plink in $doc//liking
where 
$vper/@name = $plink/@person and $xchz/@name=$plink/@cheese    
return
<td>
{xs:string ($vper/@name )}
</td>
I am getting the below result:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<td>John</td>
<td>John</td>
<td>Lee</td>



Thanks
-Nelly





Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView and SQL More than one result = one result DarkForce ASP.NET 2.0 Basics 0 July 20th, 2007 04:29 AM
Single crmpicco Excel VBA 2 May 10th, 2005 03:57 AM
How many Result? Mantis PHP Databases 1 April 15th, 2005 03:37 PM
ASP.Net Single Single-on with Oracle Application S guhanath Oracle 0 October 6th, 2004 05:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.