The following is my configuration file.
Who could tell me that how to add detail url address to the generated xml file in <xq-expression> element.
Note:in <loop item="detailUrl" index="i" maxloops="30">, detailUrl variable is each details url in the list page(start url). i want to add the detailUrl to the generated xml file.
I have tried to write like that:
Hi,All:
The following is my configuration file.
Who could tell me that how to add detail url address to the generated xml file in <xq-expression> element.
Note:in <loop item="detailUrl" index="i" maxloops="30">, detailUrl variable is each details url in the list page(start url). i want to add the detailUrl to the generated xml file.
I have tried to write like that:
<xquery>
<xq-param name="doc">
<html-to-xml>
<http url="${detailUrl}" />
</html-to-xml>
</xq-param>
<xq-param name="url">
<var name="detailUrl"/>
</xq-param>
<xq-expression>
<![CDATA
let $title := data($doc//title)
......
return
<result>
<url>{normalize-space($url)}</url>
......
</result>
]>
</xq-expression>
=====================================================================================================
<config charset="GBK">
<var-def name="startUrl">
<template>http://search.china.alibaba.com/search/offer_search.htm?keywords=MP3&tracelog=ui_chinaindex_searchbuyer</template>
</var-def>
<var-def name="urlList">
<xpath expression="//div[@class='info' or @class='info3j']/a[1]/@href">
<html-to-xml>
<http url="${startUrl}" />
</html-to-xml>
</xpath>
</var-def>
<var-def name="results">
<file action="write" path="results.xml" charset="GBK">
<template>
<![CDATA[
<?xml version="1.0" encoding="GBK"?>
<results keywords="MP3">
]]>
</template>
<loop item="detailUrl" index="i" maxloops="30">
<list>
<var name="urlList" />
</list>
<body>
<xquery>
<xq-param name="doc">
<html-to-xml>
<http url="${detailUrl}" />
</html-to-xml>
</xq-param>
<xq-expression>
<![CDATA
let $title := data($doc//title)
let $company := data($doc//td[@style="font-size:25px; padding-left:15px; padding-right:5px;"/font[1])
let $linkman := data($doc//td[@class="c lh13"][1])
let $telephone := data($doc//div[@id="contactInfoDiv"]/table/tr[1]/td[2])
let $mobile := data($doc//div[@id="contactInfoDiv"]/table/tr[2]/td[2])
let $fax := data($doc//div[@id="contactInfoDiv"]/table/tr[3]/td[2])
let $address := data($doc//div[@id="contactInfoDiv"]/table/tr[4]/td[2])
let $postalcode := data($doc//div[@id="contactInfoDiv"]/table/tr[5]/td[2]) return
<result>
<title>{normalize-space($title)}</title>
<company>{normalize-space($company)}</company>
<linkman>{normalize-space($linkman)}</linkman>
<telephone>{normalize-space($telephone)}</telephone>
<mobile>{normalize-space($mobile)}</mobile>
<fax>{normalize-space($fax)}</fax>
<address>{normalize-space($address)}</address>
<postalcode>{normalize-space($postalcode)}</postalcode>
<email/>
</result>
]]>
</xq-expression>
</xquery>
</body>
</loop>
<![CDATA
</results>
]>
</file>
</var-def>
</config>