I don9t know what I did right, but this code worked for me:
let $base :=
http-get("http://www.macosxhints.com/search.php?query=sherlock&type=stories&
mode=search")
let $htmlSearch := $base/DATA
let $searchGoods := for $searchItem in
$htmlSearch/img/table/tr/td/table/tr/td/table/tr/td/table/tr[2]/td/br/table/
/a
return dictionary(
("description", $searchItem/b/text()/convert-html(.)),
("doubleClickURL", url-with-base($searchItem/@href,
http-request-value($base, "ACTUAL_URL")))
)
return $searchGoods
And it looks like the same code. All I did was clean up the tabs and white
space at the end of lines.
For what its worth, I find that XQuery is quite flaky, things that work one
minute stop working 10 minutes later, and vice-versa. I think it has to do
with white space and tabs. Then again I just copy-pasted the code in the
original message again, deleted the new lines and space in the wrapped lines
and it worked :)
Cheers
Francois
On 4/22/03 2:19 PM, "Jussi-Pekka Mantere" <email@hidden>
wrote:
> Has anyone had luck using the O'Reilly Sherlock sample code?
> (http://www.macdevcenter.com/pub/a/mac/developer/2003/04/01/
> sherlock_two.html?page=2)
>
> I'm trying to run the following in the XQuery channel:
>
> let $base :=
> http-get("http://www.macosxhints.com/
> search.php?query=sherlock&type=stories&mode=search")
> let $htmlSearch := $base/DATA
>
> let $searchGoods := for $searchItem in
> $htmlSearch/img/table/tr/td/table/tr/td/table/tr/td/table/tr[2]/td/br/
> table//a
> return dictionary(
> ("description", $searchItem/b/text()/convert-html(.)),
> ("doubleClickURL", url-with-base($searchItem/@href,
> http-request-value($base, "ACTUAL_URL")))
> )
>
> return $searchGoods
>
> ==>
>
> (
> {
> description = "A useless but fun Sherlock easter egg";
> doubleClickURL = <null>;
> },
> {
> description = "Sherlock channel development and 10.2.4";
> doubleClickURL = <null>;
> },
> ...
> )
>
> What's wrong with this sample code?
>
> Jussi-Pekka
> _______________________________________________
> 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.
_______________________________________________
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.