Solved

Creating RSS feed from Coldfusion - XML parse error

Posted on 2011-09-19
18
2,216 Views
Last Modified: 2013-11-18
I am having trouble parsing a dataset into XML.  for some reason I keep getting this error..
This page contains the following errors:

error on line 60 at column 9: Comment not terminated
<!-- " 
error on line 94 at column 17: Comment not terminated
<!-- " ---></TD></TD></TD></TH></TH></TH></TR></TR></T
Below is a rendering of the page up to the first error.

http://www.mydomain.com/ daily http://www.mydomain.com/rugDetails.cfm?inv=118436

I have spent hours troubleshooting this page just to get to this point.  You can see I know very little about rendering XML.

Any help is greatly appreciated and I will answer all the questions you might have.  

Thanks and God Bless.
<cfsetting enablecfoutputonly="yes"><cfsetting showdebugoutput="no"><cfparam name="url.Type" default="0"><cfparam name="url.Region" default="0"><cfparam name="url.Background" default="0"><cfparam name="url.Circa" default="0"><cfparam name="url.Size" default="0"><cfparam name="url.style" default="0"><cfparam name="url.Design" default="0"><cfparam name="url.Palette" default="0"><cfparam name="url.Pattern" default="0"><cfparam name="url.minWidth" default="0"><cfparam name="url.maxWidth" default="0"><cfparam name="url.minLength" default="0"><cfparam name="url.maxLength" default="0"><cfparam name="url.StartPage" default="1" /><cfparam name="url.MaxRows" default="1000" /><cfparam name="url.inv" default="0" /><cfmodule id="SearchForm" template="ews/tags/EWSTagSearchAction.cfm" attributecollection="#url#">
<cfheader name="Content-type" value="text/xml">
<cfheader name="Pragma" value="public">
<cfheader name="Cache-control" value="private">
<cfheader name="Expires" value="-1">
<cfsetting enablecfoutputonly="no"><urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
			xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
  <loc>http://www.mydomain.com/</loc>
  <changefreq>daily</changefreq>
</url><cfoutput query="results">
<url>
  <loc>http://www.mydomain.com/rugDetails.cfm?inv=#rid#</loc>
	<image:image>
		 <image:loc>#xmlParse(trim(request.makehtmlsafe(storedisplaythumbnail)))#></image:loc> 
	</image:image>	
  <changefreq>weekly</changefreq>
</url></cfoutput>
</urlset>

Open in new window

0
Comment
Question by:jtheriau
  • 10
  • 7
18 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 36561362
The upper snippet does not contain syntax errors.
Perhaps this included template has problems:
<cfmodule id="SearchForm" template="ews/tags/EWSTagSearchAction.cfm" attributecollection="#url#">
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36561418
Comment not terminated
<!-- " --->


Seems like you're missing a dash at the beginning of a CF comment.  CF comments have 3 dashes at the beginning and end.

         <!--- 3 dashes make a CF comment --->


HTML comments only have 2 dashes

         <!-- HTML comments have only 2 dashes -->
0
 

Author Comment

by:jtheriau
ID: 36561502
Zvonko  - the included template works on other cf pages and returns the expected results.  Also - if run a cfdump prior to trying t o make the xml - I get a long list of the ids I am expecting and the links I am expecting - properly escaped.  I can 99.9% rule out the cfmodule simply because it functions everywhere else it should.  If that makes sense.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 52

Expert Comment

by:_agx_
ID: 36561508
Hm.. maybe that error isn't in your code.  Can you post the full error message?
0
 

Author Comment

by:jtheriau
ID: 36561536
agx - I am aware of the commenting structure of cf and html - thank you for covering the basics however :)  However in all the pages used in this system - I have already searched out the comments and all are seemingly properly opened and closed as cf comments.  

The interesting thing is that cf comments should not even show up in the rendering of the page - they shouldn't even show up as html comments - they are gone before the client side see the page.  However it makes me wonder does cfheader still 'see' them?  I don't know.

Anyway -  I am still looking at the comments and trying to hunt down any unclosed ones - and have found nothgin yet.
0
 

Author Comment

by:jtheriau
ID: 36561548
that was the full error .  The page ended after the id 118436
0
 

Author Comment

by:jtheriau
ID: 36561588
You know - the line that reads <!-- " ---></TD></TD></TD></TH></TH></TH></TR></TR></T  makes me think - I wonder if the cfmodule is in fact throwing an error for some reason  - or the makehtmlsafe function is throwing an error and cfheader is then trying to make an xml file out of a CF error page?

That string of table elements is very often how CF dumps it's errors.  -hmmmm?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36561652
@jtheriau - Sorry, my bad.  I didn't read closely enough the first time around ;-) Need more coffee.

>> However it makes me wonder does cfheader still 'see' them?

I don't think so. As you said, the CF server should parse those out long before anything gets sent to the client.

>> #xmlParse(trim(request.makehtmlsafe(storedisplaythumbnail)))#

Have you tried debugging smaller chunks of the code? Just to get an idea where the problem is. For example, comment out everything except the cfmodule. Does it work with the same test parameters? If yes, add back the <cfoutput query="..">#xmlParse()</cfoutput> section.  If all the dynamic data parts work, that would suggest it's an issue with the XML.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36561662
>> That string of table elements is very often how CF dumps it's errors.  -hmmmm?

Exactly! ;-)
0
 

Author Comment

by:jtheriau
ID: 36561806
It is painful - I can dump all the records and they come out just fine. I would have expected maybe the query was timing out.

 I have tried the following:

#xmlParse(storedisplaythumbnail)#
#xmlParse(request.makehtmlsafe(storedisplaythumbnail))#
#xmlParse(trim(request.makehtmlsafe(storedisplaythumbnail)))#

All of them result in the same error on the same line.  
Here is the offending page.  http://peterpap.com/createxmlsitemap.cfm  

I have to step out for an hour but I will get right back into it on my return - thanks for the help
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36562216
>> Style=2&search=all">

I have a meeting and have to head out.  

IF that error's correct, it looks like it's choking on an un-escaped "&" in the text.  Shouldn't that be Style=2&amp;search=all   instead?

0
 

Author Comment

by:jtheriau
ID: 36562349
I'm not seeing where you see Style=2&amp;search=all  ???

Interestingly - I also did not realize there was more error below the line
"
Below is a rendering of the page up to the first error.
http://www.mydomain.com/ daily http://www.mydomain.com/rugDetails.cfm?inv=118436"

The error is all in white text on a white background.  I only just now viewed the source and saw more code :)

However the error below what I could see says
"An error occured while Parsing an XML document. The element type "link" must be terminated by the matching end-tag "".
The error occurred on line 20.
"

There is no "link" in my xml.  Is that the "url" ?  Now I am really lost.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36562902
>> Here is the offending page.
>> I'm not seeing where you see Style=2&amp;search=all  ???

   I saw it by doing a view source of that page

>> There is no "link" in my xml.
>>  Is that the "url" ?  
I don't see that error. But I think they're referring to <link> tags like you've got here:

<link href="http://www.yoursite.com/css/simple.css" rel="stylesheet" type="text/css" />
<link media="print" href="http://www.yoursite.com/css/print.css" rel="stylesheet" type="text/css" />



0
 

Author Comment

by:jtheriau
ID: 36563073
what browser are you using?  I do not get links to the style sheets in my view source.  I am loading the page in Chrome.  In IE I can't even view he source - it yells at me saying there is no xml source page
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 36563117
Firefox.  

I'm getting confused about where the problem is and what you've tried so far :)  If you get rid of the headers (specifically the content-type), can you display the results at all?

If not, try wrapping the entire thing (minus the headers) in a cfsavecontent instead. Then post it so we can see it. You should be able to display it with <pre> / htmleditFormat(). If not try saving it to a file instead.



0
 

Author Comment

by:jtheriau
ID: 36563362
ok - if I remover the headers I get the following..

An error occured while Parsing an XML document.

The element type "link" must be terminated by the matching end-tag "</link>".
 
The error occurred in C:/Domains/peterpap.com/wwwroot/createXMLSitemap.cfm: line 16
14 :   <loc>http://www.peterpap.com/rugDetails.cfm?inv=#rid#</loc>
15 :       <image:image>
16 :              <image:loc>#xmlParse(trim(request.makehtmlsafe(storedisplaythumbnail)))#</image:loc>
17 :       </image:image>      
18 :   <changefreq>weekly</changefreq>
0
 

Author Comment

by:jtheriau
ID: 36563422
Ok - here is what I have realized.  What I am trying to accomplish is a live feed for a sitemap file.  

However this is all in a cfm file and the search engines are looking specifically for sitemap.xml.  So I can't even use all that I have be spending our time on.  I need to run a file to output a file called sitemap.xml in order that search engines will read it.  

So instead I have edited the file to do something a little different...

<cfquery name ='results'>blah blah blah</cfquery>
<cfxml variable="mydoc">
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
                  xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
  <loc>http://www.peterpap.com/</loc>
  <changefreq>daily</changefreq>
</url>
<cfoutput query="results">
<url>
  <loc>http://www.peterpap.com/rugDetails.cfm?inv=#rid#</loc>
      <image:image>
             <image:loc>#xmlformat(trim(request.makehtmlsafe(storedisplaythumbnail)))#</image:loc>
      </image:image>      
  <changefreq>weekly</changefreq>
</url></cfoutput>
</urlset>

</cfxml>
<cfset mydoc = replace(mydoc, "UTF-8", "ISO-8859-1")>
<!---
 dump the resulting XML document object
<cfdump var=#mydoc#><cfabort>--->
<!--- Write the XML to a file --->
<cffile action="write" file="C:/...../sitemap.xml"
      output=#toString(mydoc)#>

This then creates the following file... http://peterpap.com/sitemap.xml  Which Chrome tells me
This XML file does not appear to have any style information associated with it.

However google's validator says it is ok :)  So I think we are done trying to figure this out for now.  I am very grateful for the help and agx - you will get all the points for this one for sure.  I appreciate the amount of time you spent with this one.

If I have troubles with this file I will open a new ticket.  Thanks again an God Bless!!!
0
 

Author Closing Comment

by:jtheriau
ID: 36563430
The trouble was not resolved - but the problem was not what I thought.  Thanks for hte effort on this one!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question