2

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>
stacktraceyo
  • 1,235
  • 4
  • 16
  • 22
  • I'd recommend not using actual work related information in your posts, more generic questions are better for security and your client. – user2522076 Jun 25 '13 at 23:40

2 Answers2

0

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

DTukans
  • 339
  • 2
  • 7
  • Everything inside a CDATA section is ignored by the parser. So all inside will be represented as simple text. so you can write there html or other code inside. To show or hide cdata contents is configurable on parser, read more about cdata and parsers – DTukans Jul 27 '12 at 11:58
  • can someone please tell me where the xml file is located. i'm running the standalone version of webharvest. i'm running it's own default examples (google images) but i still don't know where are my xml files that contain the data. – disasterkid Nov 02 '12 at 15:44
0

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>
Chemik
  • 1,459
  • 13
  • 23