我的webharvest运行没有错误,但是当我打开XML文件时它没有正确的数据,它只是打印出来。这是我的代码:
<?xml version="1.0" encoding="UTF-8"?>
<config charset="ISO-8859-1">
<file action="write" path="c:/Users/Username/Desktop/out.xml" charset="UTF-8">
<xquery>
<xq-param name="doc">
<html-to-xml>
<http url="http://www.realtor.com/realestateandhomes-detail/733-Weston-Park-Dr_Powell_OH_43065_M47208-73179"/>
</html-to-xml>
</xq-param>
<xq-expression><![CDATA[
declare variable $doc as node() external;
let $add := data($doc//div[@class="address"])
let $est := data($doc//div[@class = "estValue"])
let $bed := data($doc//div[@class="beds"])
let $bath := data($doc//div[@class="baths"])
let $lot := data($doc//div[@class="acres"])
let $sqft := data($doc//div[@class="sqft"])
return
<house>
<add>{data($add)}</add>
<est>{data($est)}</est>
<bed>{data($bed)}</bed>
<bath>{data($bath)}</bath>
<lot>{data($lot)}</lot>
<sqft>{data($sqft)}</sqft>
</house>
]]></xq-expression>
</xquery>
<![CDATA[ </realtor> ]]>
</file>
</config>
答案 0 :(得分:0)
检查创建XML内容的代码,例如,我没有看到“realtor”打开标记。在“xq-expression”???
中是否真的是正确的内容答案 1 :(得分:0)
如果要打印变量值 {$ variable} 而不是 {data($ variable)}
return
<house>
<add>{$add}</add>
<est>{$est}</est>
<bed>{$bed}</bed>
<bath>{$bath}</bath>
<lot>{$lot}</lot>
<sqft>{$sqft}</sqft>
</house>