I am using a tool web harvest to scrape data from a website. I used xquery to output data as an xml file. I need to use a variable tag, for which I tried using the following:
for $i in (4 to ($count - 2))
return <concat("detail", $i)>{$doc//td[@class='body_copy']/b/../text()[$i]}</concat("detail", $i)>
This doesn't work. I also tried putting {} as in <{concat("detail", $i)}>
Any idea how to accomplish this? Or is it not achievable or not advisable?
Your syntax to build element dynamically is wrong. Try this way:
...
element{concat("detail", $i)}{$doc//td[@class='body_copy']/b/../text()[$i]}
...
Result will be a detailN
element containing the result of the expression in the seccond pair of curly braces.