Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
变量作为xml输出的标记_Xml_Xpath_Xquery_Webharvest - Fatal编程技术网

变量作为xml输出的标记

变量作为xml输出的标记,xml,xpath,xquery,webharvest,Xml,Xpath,Xquery,Webharvest,我正在使用WebHarvest工具从一个网站上抓取数据。我使用xquery将数据输出为xml文件。我需要使用变量标记,为此我尝试使用以下方法: for $i in (4 to ($count - 2)) return <concat("detail", $i)>{$doc//td[@class='body_copy']/b/../text()[$i]}</concat("detail", $i)> 对于$i in(4到($count-2)) 返回{$doc//td[@

我正在使用WebHarvest工具从一个网站上抓取数据。我使用xquery将数据输出为xml文件。我需要使用变量标记,为此我尝试使用以下方法:

for $i in (4 to ($count - 2)) 
return <concat("detail", $i)>{$doc//td[@class='body_copy']/b/../text()[$i]}</concat("detail", $i)>
对于$i in(4到($count-2))
返回{$doc//td[@class='body_copy']/b/./text()[$i]}
这不管用。我还试着在

你知道如何做到这一点吗?或者这是不可行的还是不可取的?

动态构建元素的语法是错误的。试着这样做:

...
element{concat("detail", $i)}{$doc//td[@class='body_copy']/b/../text()[$i]}
...
结果将是一个
detailN
元素,包含第二对花括号中表达式的结果