469,361 Members | 2,264 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,361 developers. It's quick & easy.

XQuery - data($node + $xpath) ?

103 100+
Hi

I know the title's a bit odd. I'm trying to set up an XQuery for which the xpath is set previously according to input parameters.

If I was going to do this normally I'd do something like:

Expand|Select|Wrap|Line Numbers
  1. let $first := data($node//h2)
  2.  
And this would get the h2 tags from the node.

But I want to set $path= 'h2' before the xquery and then...

Expand|Select|Wrap|Line Numbers
  1. let $first := data($node$path)
  2.  
or I tried
Expand|Select|Wrap|Line Numbers
  1. let $first := data(concat($node,$path))
  2.  
Can anyone help? I think the problem is that $node is a node() type and $path is a string type so how can I join them in the same way as if I'd typed //h2?

Thanks in advance!
Dec 13 '07 #1
2 1555
jkmyoung
2,057 Expert 2GB
What this ends up being is an attempt to dynamically evaluate an xpath. Due to the way the majority of compilers for XQuery work, this isn't possible without the use of extension functions or other workarounds, which are often processor dependent.

What XQuery processor are you using?
Do you know the general structure of the xpath?
Dec 13 '07 #2
henryrhenryr
103 100+
Hi - thanks for your reply!

What XQuery processor are you using?
I'm using web harvest - (http://web-harvest.sourceforge.net). I've found most functions I've tried work - well they don't break it! Let me know which ones I should try and I'll give it a try.

Do you know the general structure of the xpath?
I'm not 100% sure what you mean here... I'm using XPath to read HTML sites. So the structure I'm trying to capture is pretty much standard (although normally messy) HTML.

I am using the software for a number of different sites and I want to have the same set of processors used for various tasks - I will input the XPath to identify particular parts of a node that I want but that varies between different tasks so I need a dynamic solution...

Hope that makes it clearer. Thanks for your help!
Dec 14 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Jeff Kish | last post: by
7 posts views Thread by Zaharije Pasalic | last post: by
4 posts views Thread by Steve Richter | last post: by
3 posts views Thread by Bloody Viking | last post: by
1 post views Thread by greg | last post: by
2 posts views Thread by arunairs | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.