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

CDATA in RSS using Coldfusion

New Here ,
Jul 09, 2006 Jul 09, 2006
I ma using Coldfusion 4.5 (yes I know it's old but it's what I have to work with) to generate a dynmaic RSS feed. The problem I have encounterd is that some of the fields (overview) inside the DB have HTML in them, and even with the CDATA tags in place within the Item/Description tags, it is blowing up. Is there any way to get it to appear correctly?

<description><![CDATA[#overview#]]</description>

Thanks.
1.3K
Translate
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
New Here ,
Jul 10, 2006 Jul 10, 2006
Can you describe what you mean by 'blowing up'?

looks like you're not closing your CDATA properly. Might need another '>' sign. Check out here for more on that:
http://www.dpawson.co.uk/xsl/sect2/cdata.html

you might consider this debate on CDATA vs. escaping the html characters:
http://www.sagewire.org/xml/CDATA-vs-Escaping-XML-Characters-233473.aspx
Translate
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
New Here ,
Jul 10, 2006 Jul 10, 2006
Typo on my behalf in the post above, it is definately entered as
<description><![CDATA[#overview#]]></description>

The DB field (overview) contains:

Text

<ul>
<li><strong>text</strong></li>
<li><strong> text</strong></li>
</ul>
text<a hreflink.htm">Blah website</a> for further details.

The error it get is:

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

An invalid character was found in text content. Error processing resource ' http://url/tenders.cfm'. Line 16, Position 46


<li><strong> text


Translate
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
New Here ,
Jul 11, 2006 Jul 11, 2006
can you post a sample of the bad xml?
Translate
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
New Here ,
Jul 11, 2006 Jul 11, 2006
sorry I missed your xml this morning... hadn't had my coffee yet.

Save out the xml to a file, like test.xml, remove any reference to a stylesheet from the xml (if you have one in there), then open that file in IE. It should roughly pinpoint the invalid character. Any reason you couldn't htmlencode the value in the <description> node and leave out the CDATA?
Translate
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
New Here ,
Jul 11, 2006 Jul 11, 2006
Can you please explain how I would htmlencode it instead of using CDATA??

Thanks.

quote:

Originally posted by: sagewire
sorry I missed your xml this morning... hadn't had my coffee yet.

Save out the xml to a file, like test.xml, remove any reference to a stylesheet from the xml (if you have one in there), then open that file in IE. It should roughly pinpoint the invalid character. Any reason you couldn't htmlencode the value in the <description> node and leave out the CDATA?


Translate
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
LEGEND ,
Jul 11, 2006 Jul 11, 2006
If you have access to Firefox, I find it better at detecting bad markup
in the XML. It will put question marks in black diamonds where the
markup is questionable, but it will ontinue to display the rest of the
XML file instead of aborting at the first problem.


sagewire wrote:
> sorry I missed your xml this morning... hadn't had my coffee yet.
>
> Save out the xml to a file, like test.xml, remove any reference to a
> stylesheet from the xml (if you have one in there), then open that file in IE.
> It should roughly pinpoint the invalid character. Any reason you couldn't
> htmlencode the value in the <description> node and leave out the CDATA?
>
Translate
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
New Here ,
Jul 11, 2006 Jul 11, 2006
nm, your rss reader likely would just display the encoded html. Sounds like your question really gets down to the xslt syntax required to transform a cdata block.
Translate
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
New Here ,
Jul 11, 2006 Jul 11, 2006
After thinking about it some more I don't think that htmlencoding would help since it would end up garbled looking to your human rss readers. The function I was thinking about is this though: URLEncodedFormat

Anyway, check out your xslt file. I'm pretty sure that's where you'll find the problem. Try removing the cdata tag and put some valid xml or plain text inside your <description> node then try your transformation again. If it works, then ressearch using cdata inside an xslt.

good luck!
Translate
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
New Here ,
Jul 11, 2006 Jul 11, 2006
LATEST
Thanks I found the offending characters when viewing it in firefox. It as an ms word generated ' and - that was causing the problems. This leads me to another question though, is is possible to use the "replace" function in Coldfusion to replace the characters that the XML rejects in an RSS Feed? Is there a way of listing all possibilites and the replacements for them in one hit?

Cheers.
Translate
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