473,379 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

XML Feed Code Error

Hello,
I'm new to both RSS & XML and I am trying to create a ColdFusion RSS feed. I have my cfm file with all my code and at the end of the file I am writing that output to an XML file. At the top of my page, I am setting variables, and queries and then here is the rest of my code.

<cfsetting enablecfoutputonly="yes">
<cfsavecontent variable="theXML">
<cfoutput>
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
<title>Morning Bond Comment</title>
<link>http://mywebsite.com/</link>
<description>Latest Bond Market Comment</description>
<language>en-us</language>
<copyright>Copyright 2007</copyright>
<docs>http://backend.userland.com/rss/</docs>
<lastbuilddate>#theDatetime#</lastbuilddate>
<item>
<pubDate>#CommentDate#</pubDate>
<title>#CommentHeadline#</title>
<description>#BondComment#</description>
</item>
</channel>
</rss>
</cfoutput>
</cfsavecontent>

<cffile action="write" file="#expandPath(".")#\c_bond_comment_feed.xml" output="#theXML#">

<cfcontent type="text/xml">
<cfoutput>#theXml#</cfoutput>

When I go to view the RSS, I get a Feed Code Error saying
Invalid xml declaration.
Line: 2 Character: 3

<?xml version="1.0" encoding="iso-8859-1"?>


I have tried different encoding structures. Does anyone see what I am doing wrong? Any help will be very much appreciated.
Jun 5 '07 #1
7 5380
dorinbogdan
839 Expert 512MB
Welcome to TheScripts TSDN....

I'm not sure if works here too (regularly it's the XML standard), but try to set it as the first line
<?xml version="1.0" encoding="iso-8859-1"?>

I will post a link to this question in the Coldfusion forum too.

Dorin.
Jun 6 '07 #2
acoder
16,027 Expert Mod 8TB
Try moving the cfoutput outside the cfsavecontent tag or have them around each separate variable instead.
Jun 6 '07 #3
Welcome to TheScripts TSDN....

I'm not sure if works here too (regularly it's the XML standard), but try to set it as the first line
<?xml version="1.0" encoding="iso-8859-1"?>

I will post a link to this question in the Coldfusion forum too.

Dorin.
Thank you. Putting that at the very top, got me further than what I was yesterday.
Jun 6 '07 #4
Try moving the cfoutput outside the cfsavecontent tag or have them around each separate variable instead.

Thank you for your suggestions and I tried them. As soon as I put the cfoutput around each variable, I get another error saying "Invalid at the top level of the document." I'm not even sure how to fix that error. I do like the fact that none of the start tags and end tags are showing on the source.

When I tried to put the cfoutput on the outside of the cfsavecontent tag, on the view source of the browser, it will show all information from the start of the <rss> tag to the </rss> tag.

Any more suggestions?
Jun 6 '07 #5
acoder
16,027 Expert Mod 8TB
Thank you for your suggestions and I tried them. As soon as I put the cfoutput around each variable, I get another error saying "Invalid at the top level of the document." I'm not even sure how to fix that error.
Is this a Coldfusion error or are you talking about when you view the RSS?
Jun 6 '07 #6
Is this a Coldfusion error or are you talking about when you view the RSS?
No, this is an error I get when I am trying to view the feed in the IE7 & IE6. Then when I test it in FireFox and Netscape 9, I get the error "XML Parsing Error: not well-formed". I'm guessing that it doesn't like the dateformat of 06/06/07.
Jun 6 '07 #7
Hi,

Here are things you should try or post ur xml output to the forum.

Why dont you try to make all strings XML safe by using #XMLFormat(string)# function?

And you should not be writing the variable to file, unless you want to store it permanently.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <cfcontent type="text/xml" reset="yes">
  3. <cfprocessingdirective suppresswhitespace="yes">
  4. <cfoutput>
  5. <?xml version="1.0" encoding="iso-8859-1"?> 
  6. <rss version="2.0">
  7.     <channel>
  8.         <title>Morning Bond Comment</title>
  9.         <link>http://mywebsite.com/</link>
  10.         <description>Latest Bond Market Comment</description>
  11.         <language>en-us</language>
  12.         <copyright>Copyright 2007</copyright>
  13.         <docs>http://backend.userland.com/rss/</docs>
  14.         <lastbuilddate>#theDatetime#</lastbuilddate>
  15.         <item>
  16.             <pubDate>#CommentDate#</pubDate>
  17.             <title>#CommentHeadline#</title>
  18.             <description>#BondComment#</description>
  19.         </item>
  20.     </channel>
  21. </rss>
  22. </cfoutput>
  23. <cfabort>
  24. </cfprocessingdirective>
  25.  
Jun 11 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
6
by: Martman | last post by:
I am new to PHP but testing the ability to read an RSS xml feed. I have successfully retrieved, read, and displayed an RSS feed from pcworld. However, when you click on one of the links it adds...
5
by: Sonal | last post by:
Hi I am trying to provide infrastructure for RSS feeds on my Website. I dont intend to build any news aggregators. I just want my website to be enabled for providing RSS Feeds. I am using ASP.NET...
1
by: Steve | last post by:
I have a script that has been modified from one that I found on the internet to display RSS feeds in html. The script works fine for most RSS feeds but there are a number that it fails on with the...
5
by: sck10 | last post by:
Hello, I am using the following to get RSS Feeds. I've been able to get the xml files from every site except CNN. When I try to get there feed, I get the exception: A column named 'link'...
8
by: Steve | last post by:
Can any see why Magpie RSS won't accept this RSS Feed (that is valid according to the Feed Validator website). http://www.westyorksprobation.org.uk/rss.php?type=Library This is the code that...
4
by: Blake Garner | last post by:
I'm looking for suggestions on how to approach generating rss feed ..xml files using python. What modules to people recommend I start with? Thanks! Blake
2
jamwil
by: jamwil | last post by:
What's up guys. I'm having some issues... I've created a method as part of my lifestreaming class which takes an rss feed, and puts the data into a database... It's fairly simple... Check...
4
by: jrod11 | last post by:
I have an RSS reader that I have been using, but the only problem i have is that I want the target to be "_blank" rather than the parent window. Anyone know where I should add the _blank? ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.