Wonder
Wonder

Reputation: 1020

Html tags in xml (rss)

Followed http://damieng.com/blog/2010/04/26/creating-rss-feeds-in-asp-net-mvc to create RSS for my blog. Everything fine except html tags in xml document. Typical problem:

<br /> 

insted of

<br />

Normally I would use

@HtmlRaw()

or

MvcHtmlString()

But how can I fix it in XML document created with SyndicationFeed?

Edit: Ok, I'm starting to think that my question is pointless. Should I just leave my RSS as it is?

Upvotes: 1

Views: 273

Answers (2)

Rafay
Rafay

Reputation: 31033

wrap the text in side the CDATA

var xml= '<person><name><![CDATA[<h1>john smith</h1>]]></name></person>',
    xmlDoc = $.parseXML( xml ),
    $xml = $( xmlDoc ),
    $title = $xml.find( "name" );


$($title.text()).appendTo("body");

DEMO

Upvotes: 0

TheGeekYouNeed
TheGeekYouNeed

Reputation: 7539

With the XML element, you can wrap the text with your HTML in it in as a CDATA section:

<![CDATA[ 

   your html


]]>

I don't recommend doing that, however.

Upvotes: 1

Related Questions