471,886 Members | 1,084 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,886 software developers and data experts.

XQuery - data($node + $xpath) ?

103 100+

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)
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)
or I tried
Expand|Select|Wrap|Line Numbers
  1. let $first := data(concat($node,$path))
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 1612
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
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
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.