I am pulling info from zillow and then setting a price based on sq ft of the house. I am also using zillow to pull lat and lon to pull up a google map on the property the problem in some homes don't have sq footage and my cold fusion is returning an error cause it needs a variable this is my xml code to pull the data from zillow.

It's failing at QuerySetCell(xmlqry,"zlot",xmlfile.searchresults.response.results.result[a].lotSizeSqFt.xmlText,a);
cause some property's don't have this info can I check to see if this info is there first then continue.

If it is not there can I set the variable myself it can be 0 or nothing.

<CFHTTP url="http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=X1-<ZSID>&cmd=locate&address=#form.vcAddress1#&citystatezip=#form.vcCity#+#form.numZip#" method="get">
                <cfset xmlDoc = XMLParse(cfhttp.filecontent)>
                <cfset code = #xmlDoc.searchresults.message.text#>
                <cfif #code# contains "successfully">
                <cfscript>
                xmlfile = xmlparse(cfhttp.filecontent); //Parses the XML
                xmlsize = arraylen(xmlfile.searchresults); //Tutorials is the parent tree
                xmlqry = QueryNew("zlot, zcode, url, author, platform, descr"); //Sets a query for output
                QueryAddRow(xmlqry,xmlsize);
                for(a=1;a LTE xmlsize;a=a+1) {
                QuerySetCell(xmlqry,"zlot",xmlfile.searchresults.response.results.result[a].lotSizeSqFt.xmlText,a);
                QuerySetCell(xmlqry,"zcode",xmlfile.searchresults.message[a].text.xmlText,a); 
                   }
               </cfscript>

    <cfquery name="GetSqFt" dbtype="query">
    SELECT        *
    FROM           xmlqry
    ORDER BY     zlot DESC
   </cfquery>

I had this same problem... and it took me forever to solve it... here is what I do.

Lots of the properties result with missing elements... you have to check each one before you attempt to load them into your query.

if (not ArrayIsEmpty(XmlSearch(xmlDoc, "//*/results/result[#a#]/lotSizeSqFt")))
QuerySetCell(xmlqry,"lotSizeSqFt",xmlfile.searchresults.response.results.result[a].lotSizeSqFt.xmlText,a);
else QuerySetCell(xmlqry,"lotSizeSqFt",0,a);

I hope this helps... I could not get any help on the problem a few days ago... I had to grind it out for HOURS!!!!!

-Mark

I am pulling info from zillow and then setting a price based on sq ft of the house. I am also using zillow to pull lat and lon to pull up a google map on the property the problem in some homes don't have sq footage and my cold fusion is returning an error cause it needs a variable this is my xml code to pull the data from zillow.

It's failing at QuerySetCell(xmlqry,"zlot",xmlfile.searchresults.response.results.result[a].lotSizeSqFt.xmlText,a);
cause some property's don't have this info can I check to see if this info is there first then continue.

If it is not there can I set the variable myself it can be 0 or nothing.

<CFHTTP url="http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=X1-<ZSID>&cmd=locate&address=#form.vcAddress1#&citystatezip=#form.vcCity#+#form.numZip#" method="get">
                <cfset xmlDoc = XMLParse(cfhttp.filecontent)>
                <cfset code = #xmlDoc.searchresults.message.text#>
                <cfif #code# contains "successfully">
                <cfscript>
                xmlfile = xmlparse(cfhttp.filecontent); //Parses the XML
                xmlsize = arraylen(xmlfile.searchresults); //Tutorials is the parent tree
                xmlqry = QueryNew("zlot, zcode, url, author, platform, descr"); //Sets a query for output
                QueryAddRow(xmlqry,xmlsize);
                for(a=1;a LTE xmlsize;a=a+1) {
                QuerySetCell(xmlqry,"zlot",xmlfile.searchresults.response.results.result[a].lotSizeSqFt.xmlText,a);
                QuerySetCell(xmlqry,"zcode",xmlfile.searchresults.message[a].text.xmlText,a); 
                   }
               </cfscript>

    <cfquery name="GetSqFt" dbtype="query">
    SELECT        *
    FROM           xmlqry
    ORDER BY     zlot DESC
   </cfquery>

Thanks, That worked!

Here was the complete code

<!--- This code Pulls zillow housing info. --->

                  <!--- Exmple XML URL FOR TESTING http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=<ZSID GOES HERE> &address=20+parkerville+Ct&citystatezip=west chester%2C+PA --->

                <CFHTTP url="http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=<ZSID GOES HERE> &cmd=locate&address=#form.vcAddress1#&citystatezip=#form.vcCity#+#form.numZip#" method="get">
                <cfset xmlDoc = XMLParse(cfhttp.filecontent)>
                <cfset code = #xmlDoc.searchresults#>
                <cfif #code# contains "successful">
                <cfscript>
                xmlfile = xmlparse(cfhttp.filecontent); //Parses the XML
                xmlsize = arraylen(xmlfile.searchresults); //Tutorials is the parent tree
                xmlqry = QueryNew("zlot, zcode, url, author, platform, descr"); //Sets a query for output
                QueryAddRow(xmlqry,xmlsize);
                for(a=1;a LTE xmlsize;a=a+1) {
                if (not ArrayIsEmpty(XmlSearch(xmlDoc, "//*/results/result[#a#]/lotSizeSqFt")))
QuerySetCell(xmlqry,"zlot",xmlfile.searchresults.response.results.result[a].lotSizeSqFt.xmlText,a);
else QuerySetCell(xmlqry,"zlot",0,a);  //Searches zillow XML for Sq Foot Size. If not found returns 0
                   }
               </cfscript>

<!--- Get The Variables from the XML Sheet. --->

    <cfquery name="GetSqFt" dbtype="query">
    SELECT        *
    FROM           xmlqry
    ORDER BY     zlot DESC
   </cfquery>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.