logo       

getting an attrib value from another attrib value: msg#00004

Subject: getting an attrib value from another attrib value
This is a multi-part message in MIME format.

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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
region.costa-ri...    user-groups.lin...    lang.prothon.us...    xfree86.cvs/200...    finance.aqbanki...    ietf.smtp/1993-...    web.turbogears....    jakarta.cactus....    yellowdog.gener...    php.gtk+.genera...    org.region.indo...    hurd.l4/2005-10...    culture.religio...    apple.fink.gene...    db.mysql.window...    bluez.devel/200...    security.pgp-ba...    video.blender.d...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe