For the first cell use //tr[@class='addresstitle']. That is one part of information. For Chrompet you need different xpath etc. However you may use XQuery to combine several XPAth expressions in one Web-Harvest processor. There are lot of tutorials on web about XPath and XQuery. See for example
When using XPAth expressions it is best not to make full paths to the desired data, like "/html/body/....."
but to find soemthing specific like in example //tr[@class='addresstitle'] where addresstitle is crucial attribute.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
my xml config file look like this.
<?xml version="1.0" encoding="UTF-8"?>
<config charset="UTF-8">
<file action="write" path="myfolder/extract.xml"><template><![CDATA[ <extract time="${sys.datetime("dd.MM.yyyy,HH:mm:ss")}"> ]]></template><loop item="row"><!-- list consists of all rows in the main HTML table on the page --><list><xpath expression="//tr[@class="addresstitle"]"><html-to-xml><http url="urladdress"/></html-to-xml></xpath></list><!--
It is needed to resolve odds, date and header rows. Distinction is
made based on "class" attribute.
--><body><empty><var-def name="clazz"><xpath expression="//td/@class"><var name="row"/></xpath></var-def></empty><case><if condition='${clazz.toString()=="addresstitle"}'><xquery><xq-param name="doc"><var name="row"/></xq-param><xq-expression><![CDATA[
for $row in $doc//td return
<extract name="{normalize-space(data($row[1]))}"></extract>
]]></xq-expression></xquery></if></case></body></loop><![CDATA[ </extract> ]]></file>
</config>
when I run this i am getting the following error.
variable 'clazz' is not defined.
Is it correct config file to extract the above said data.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the help.
I want to extract some datas from a website. Sample HTML page is given.
<tr>
<td colspan="4" align="center" valign="top">
I want to scrape only GOVT HOSPITAL CHROMPET,Chrompet,22382400 only. What XPath expression i should give and can you give me some sample code.
For the first cell use //tr[@class='addresstitle']. That is one part of information. For Chrompet you need different xpath etc. However you may use XQuery to combine several XPAth expressions in one Web-Harvest processor. There are lot of tutorials on web about XPath and XQuery. See for example
http://www.w3schools.com/.
When using XPAth expressions it is best not to make full paths to the desired data, like "/html/body/....."
but to find soemthing specific like in example //tr[@class='addresstitle'] where addresstitle is crucial attribute.
my xml config file look like this.
<?xml version="1.0" encoding="UTF-8"?>
<config charset="UTF-8">
</config>
when I run this i am getting the following error.
variable 'clazz' is not defined.
Is it correct config file to extract the above said data.
Can you give me a sample code to write the extracted data to XML file using xquery
Thanks