2 Replies Latest reply on Nov 30, 2007 12:48 PM by aqlongnion

    Problems parsing XML

    Level 7
      I am attempting to create XML using data from the database. I am running
      into, probably, errant data from my provider and is causing a parsing error.

      An error occured while Parsing an XML document. The string "--" is not
      permitted within comments.

      I have no control over the source data (MLS Listings), but I need to fix it
      somehow. Can I use CDATA to negate conflicting data and be able to parse it?
      If so, how? Where should I look for an example?

      Here is my XML creation:
      <cfcontent type="text/xml; charset=utf-16">
      <cfxml variable="xmlobject">
      <properties>
      <cfoutput query="SearchResults">
      <property>
      <mlsnumber>#MLSNumber#</mlsnumber>
      <ListOfficeID>#ListOfficeId#</listofficeid>
      <propertyType>#PropertyType#</propertytype>
      <ListOfficeCompany>#ListOfficeCompany#</ListOfficeCompany>
      <basement>#Basement#</basement>
      <baths>#baths#</baths>
      <city>#City#</city>
      <conform_Zone>#Conforms_Zone#</conform_zone>
      <county>#County#</county>
      <directions>#Directions#</directions>
      <garage>#Garage#</garage>
      <listPrice>#ListPrice#</listPrice>
      <lot_Dimen>#Lot_Dimen#</lot_dimen>
      <mo_rent_inc>#Mo_Rent_Inc#</mo_rent_inc>
      <no_1Bedrooms>#No_1Bedrooms#</no_1Bedrooms>
      <no_2Bedrooms>#No_2Bedrooms#</no_2Bedrooms>
      <no_3bedrooms>#No_3Bedrooms#</no_3bedrooms>
      <no_efficiencies>#No_Efficiencies#</no_efficiencies>
      <no_units>#No_Units#</no_units>
      <remarks1>#Remarks1#</remarks1>
      <remarks2>#Remarks2#</remarks2>
      <remarks3>#Remarks3#</remarks3>
      <remarks4>#Remarks4#</remarks4>
      <remarks5>#Remarks5#</remarks5>
      <remarks6>#Remarks6#</remarks6>
      <school_district>#School_District#</school_district>
      <state>#State#</state>
      <street_dir>#Street_Dir#</street_dir>
      <streetname>#StreetName#</streetname>
      <streetnumber>#StreetNumber#</streetnumber>
      <street_type>#Street_Type#</street_type>
      <summertax>#SummerTax#</summertax>
      <tot_square_feet>#Tot_Square_Feet#</tot_square_feet>
      <winter_tax>#Winter_Tax#</winter_tax>
      <year_built>#Year_Built#</year_built>
      <zip5>Zip5</zip5>
      <basement_type>#Basement_Type#</basement_type>
      <cooling>#Cooling#</cooling>
      <exterior>#Exterior#</exterior>
      <heating>#Heating#</heating>
      <parking>#Parking#</parking>
      <home_style>#Style#</home_style>
      <zoning>#Zoning#</zoning>
      <photoURL>#PhotoURL#</photoURL>
      <displayaddress>#DisplayAddress#</displayaddress>
      <subdivisonname>#SubdivisionName#</subdivisionname>
      </property>
      </cfoutput>
      </properties>
      </cfxml>

      <cfset myvar=toString(xmlobject)>
      <cfset mynewvar=replace(myvar, "UTF-8", "utf-16")>

      <cfoutput>#mynewvar#</cfoutput>
      </cfprocessingdirective>


      And here is my transformation:
      <!---Search Residential--->
      <cffunction name="SearchResidential" access="public" returntype="xml">
      <cfargument name="bathrooms" required="yes" type="numeric">
      <cfargument name="bedrooms" type="numeric" required="yes">
      <cfargument name="cities" type="string" required="yes">
      <cfargument name="footage" type="numeric" required="yes">
      <cfargument name="minprice" type="numeric" required="yes">
      <cfargument name="maxprice" type="numeric" required="yes">
      <cfargument name="basement" type="string" required="yes">
      <cfargument name="garage" type="string" required="yes">
      <cfset URLToPull =
      " http://74.86.90.210/realitorToolBox/model/webservices/searchResidential.cfm?bathrooms=#bat hrooms#&bedrooms=#bedrooms#&cities=#cities#&footage=#footage#&minprice=#minprice#&maxprice =#maxprice#&basement=#basement#&garage=#garage#">
      <cfhttp url="#URLToPull#" method="GET" timeout="15">
      </cfhttp>
      <cfscript>
      XMLContent = trim(cfhttp.filecontent);
      XMLContent = XMLParse(XMLContent);
      </cfscript>
      <cfreturn XMLContent>
      </cffunction>

      What else can I do not to get the error?