Solved

Creating RSS feed from Coldfusion - XML parse error

Posted on 2011-09-19
18
2,204 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
Comment Utility
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_
Comment Utility
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
Comment Utility
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
 
LVL 52

Expert Comment

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

Author Comment

by:jtheriau
Comment Utility
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
Comment Utility
that was the full error .  The page ended after the id 118436
0
 

Author Comment

by:jtheriau
Comment Utility
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_
Comment Utility
@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_
Comment Utility
>> That string of table elements is very often how CF dumps it's errors.  -hmmmm?

Exactly! ;-)
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:jtheriau
Comment Utility
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_
Comment Utility
>> 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
Comment Utility
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_
Comment Utility
>> 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
The trouble was not resolved - but the problem was not what I thought.  Thanks for hte effort on this one!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now