Transform HTML to XML
There are some issues using XPath for huge documents. Sometimes, a document is valid but the XPath does not return any values due to the document formatting issues, nested comments, scripts, and TDT slow validation. This workaround can help make it working:
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<var-def name="contentValue">
<html-to-xml omitcomments="true" omithtmlenvelope="true" outputtype="pretty" prunetags="script,style">
<file action="read" path="${file}" />
</html-to-xml>
</var-def>
<!-- correct usage -->
<xpath expression="//a">
<var-def name="page">
<template><root>${contentValue.toString().replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>","")}</root></template>
</var-def>
</xpath>
<!-- bad, incorrect usage -->
<var-def name="rows">
<xpath expression="//a">
<html-to-xml>
<file action="read" path="${file}"/>
</html-to-xml>
</xpath>
</var-def>
</config>