• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Problems parsing XML

LEGEND ,
Nov 24, 2007 Nov 24, 2007

Copy link to clipboard

Copied

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=#bathrooms#&be...
<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?



TOPICS
Advanced techniques

Views

386

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 29, 2007 Nov 29, 2007

Copy link to clipboard

Copied

What is the error you are getting? Your problem could be invalid characters in your XML document. Try using the XMLFORMAT function along with your data i.e. <mlsnumber>#xmlformat(MLSNumber)#</mlsnumber>. That technique will convert invalid characters such as the "&" into a format that XMLParse can deal with.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2007 Nov 30, 2007

Copy link to clipboard

Copied

LATEST
If you want to retain the original characters, use CDATA instead of XMLFormat().

Something like:
<displayaddress><![CDATA[#DisplayAddress#]]></displayaddress>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation