[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

getting an attrib value from another attrib value

Robert Walpole robert.walpole at devon.gov.uk
Mon Dec 4 13:24:32 PST 2006


  getting an attrib value from another attrib value
Hi,

This may be more XPath than XQuery so I hope you don't mind me posting
here.

I want to write a query that given a string (let's say "Torbay") will
return the uid attribute of the element with the name attribute equal to
the string value.

I have only got so far as being able to get the whole node (i.e.
including children) with the matching name attribute as follows:

for $areaserved in doc("...")/*[@name = "Torquay"] return $areaserved

I should say that the matching name attribute could appear at any level
in the XML document and may or may not have child elements.

Example XML:

<?xml version="1.0" encoding="UTF-8"?>
<county name="Devon" uid="0">
    <district uid="8" name="Torbay">
        <town uid="210" name="Brixham" pct="Torbay"/>
        <town uid="211" name="Paignton" pct="Torbay"/>
        <town uid="212" name="Torquay" pct="Torbay">
            <settlement name="Babbacombe" uid="979"/>
            <settlement name="Barton" uid="803"/>
            <settlement name="Chelston" uid="804"/>
        </town>
    </district>
</county>

Many Thanks
Rob Walpole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20061204/dca87591/attachment.htm


Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.