webharvest not retrieving data

459 Views Asked by At

I have webharvest running without errors, but when I open the XML file it does not have the right data, it just prints it out. here is my code:

<?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>
2

There are 2 best solutions below

0
On

If you want to print value of variable use {$variable} not {data($variable)}

    return
        <house>
            <add>{$add}</add>
            <est>{$est}</est>       
            <bed>{$bed}</bed> 
            <bath>{$bath}</bath> 
            <lot>{$lot}</lot>                            
            <sqft>{$sqft}</sqft>
        </house>
2
On

check up code where you create XML contents, for example, i don't see "realtor" opening tag. And is it really correct content inside "xq-expression"???