Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Retrieving text and anchor nodes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retrieving text and anchor nodes



Ah, that's trickier.

Would be easy if our XQuery implementation supported the preceding-sibling:: axis.

let $strings = $anchors/preceding-sibling::text()

Unfortunately, neither the Jaguar nor the Panther versions support this axis.

Her is a brute force way to get what you want.

let $doc :=document("http://www.co-ops.nos.noaa.gov/tides04/tab2ec1b.html";)
let $anchors := $doc/A[text()="Predictions"]
let $rawstrings:= tokenize($doc,"<A [^<]*</A>")
let $strings :=
for $rs in $rawstrings
let $s1 := if (contains($rs,"</U>")) then substring-after($rs, "</U>") else $rs
let $s2 := if (contains($s1,"</B>")) then substring-after($s1, "</B>") else $s1
where not (contains($s2,"<"))
return $s2
return $strings


Wayne


On Feb 16, 2004, at 06:09 PM, <email@hidden> wrote:

Thanks. That is close to what I want, but I also want to get the preceding sibling text() node. For the first matching anchor in this example it should be "Newburyport, Merrimack River 420 48.7' 700 51.9' 7.8 9.0 4.2 ".

<-----Original Message----->
From: Wayne Loofbourrow
Sent: 2/16/2004 9:04:11 PM
To: email@hidden
Cc: email@hidden
Subject: Re: sherlock-channel-development digest, Vol 1 #180 - 1 msg

Try:

let $nodes :=
document("http://www.co-ops.nos.noaa.gov/tides04/tab2ec1b.html";)/
A[text()="Predictions"]/@HREF

This says to first extract those A tags whose text content is
"Predictions" and then grab the HREF attribute from each of them.

Wayne
_______________________________________________
sherlock-channel-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/sherlock-channel-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.