Skip to main content
Participant
November 3, 2015
Question

I am having trouble with an XML feed Can You Help?

  • November 3, 2015
  • 1 reply
  • 406 views

Any help would be appreciated

I have created a cf file as follows:

<cfxml variable="properties">

<cfquery name="GetPropertiesForFeed">Select PropertyReference, Price, Urbanisation, Location, PropertyType, FloorArea, Bedrooms, Bathrooms, Image1, Image2, Image3,

Image4, Image5, Image6, Image7, Image8, Description, Descriptionsp From Properties</cfquery>

<properties>

<cfloop query="GetPropertiesForFeed">

<property>

  <reference>#PropertyReference#</reference>

         <price>#Price#</price>

         <urbanisation>#Urbanisation#</urbanisation>

         <location>#Location#</location>

         <type>#PropertyType#</type>

         <area>#FloorArea#</area>

         <beds>#Bedrooms#</beds>

         <baths>#Bathrooms#</baths>

         <images>

         <image><url>http://primrose-realestate.com/propimages/#image1#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image2#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image3#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image4#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image5#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image6#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image7#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image8#</url></image>

         </images>

         <descriptions>

         <en>#Description#</en>

         <nl>#Descriptionsp#</nl>

  </descriptions>

</property>

</cfloop>

</properties>

</cfxml>

<!---<cfdump var=#properties#>--->

<cfset XMLText=ToString(properties)>

<cffile action="write" file="XMLfeed.xml" output="#XMLText#">

The xml file produced looks like this:

<properties>

<property>

<reference>#PropertyReference#</reference>

<price>#Price#</price>

<urbanisation>#Urbanisation#</urbanisation>

<location>#Location#</location>

<type>#PropertyType#</type>

<area>#FloorArea#</area>

<beds>#Bedrooms#</beds>

<baths>#Bathrooms#</baths>

<descriptions>

<en>#Description#</en>

<nl>#Descriptionsp#</nl>

</descriptions>

</property>

</properties>


The fields are not picking up the data.


Any suggestions please.

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
November 5, 2015

Use either

<cfoutput query="GetPropertiesForFeed">

</cfoutput>

or else

<cfloop query="GetPropertiesForFeed">

<cfoutput>

</cfoutput>

</cfloop>

Somethng like

<cfquery name="GetPropertiesForFeed">

    Select PropertyReference, Price, Urbanisation, Location, PropertyType, FloorArea, Bedrooms, Bathrooms, Image1, Image2, Image3,

    Image4, Image5, Image6, Image7, Image8, Description, Descriptionsp

    From Properties

</cfquery>

<cfxml variable="properties">

<properties>

<cfoutput query="GetPropertiesForFeed">

<property>

  <reference>#PropertyReference#</reference>

         <price>#Price#</price>

         <urbanisation>#Urbanisation#</urbanisation>

         <location>#Location#</location>

         <type>#PropertyType#</type>

         <area>#FloorArea#</area>

         <beds>#Bedrooms#</beds>

         <baths>#Bathrooms#</baths>

         <images>

         <image><url>http://primrose-realestate.com/propimages/#image1#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image2#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image3#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image4#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image5#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image6#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image7#</url></image>

         <image><url>http://primrose-realestate.com/propimages/#image8#</url></image>

         </images>

         <descriptions>

         <en>#Description#</en>

         <nl>#Descriptionsp#</nl>

  </descriptions>

</property>

</cfoutput>

</properties>

</cfxml>