Help - Search - Members - Calendar
Full Version: Raw HTML in XML Feed
Movable Type Community Forum > Additional Resources > Tips and Tricks
Fullman
OK, I have an XML feed, that my friends on LiveJournal are watching.

The problem is that all of the HTML gets stripped when the XML file is generated with MT.

It removes all the breaks, paragraph tags, formatting, everything. Even the images!

So if I type out a rather long post (3-4 paragrahs), it appears as this giant block of text.

Is there any way to prevent MT from stripping out the HTML in the XML feed and keep this from happening? sad.gif
scottbird
use 'remove_html="0" as an attribute to the tag in question.

eg : <$MTEntryTitle remove_html="0"$>


Cheers,

Scott
TweezerMan
In a word, yes - but if not done properly, you can break your XML feed.

Look for the following line in your RSS 2.0 Index template:

CODE
<description><$MTEntryExcerpt remove_html="1" encode_xml="1"$></description>

The HTML is removed by two things:

1) The MTEntryExcerpt tag itself, if you do not explicitly enter an excerpt with your post. According to the manual:

QUOTE
MTEntryExcerpt
The excerpt of this entry. If you have not provided an excerpt for this entry, the first 20 words of the entry, followed by an ellipsis (...) will be used, instead.

When you don't provide an excerpt for a post, the HTML is stripped from your post text first, before figuring out the 20 words of text to use, so that there are no broken or unclosed HTML tags in the excerpt.

2) The remove_html="1" attribute explicitly tells MT to remove HTML tags from the entry excerpt, whether the excerpt is provided by you or generated by MT.

To keep MT from removing the HTML from your XML feed while still creating a valid XML feed, both causes must be addressed:

1a) Use MTEntryBody instead of MTEntryExcerpt. This will include the full text of your posts in your XML feed (which you may or may not want to do).

-- OR --

1b) Keep the MTEntryExcerpt tag. Be sure to always enter your own excerpt text for MT to use in the "Excerpt" box so MT won't have to figure out an excerpt on its own.

-- THEN --

2) Remove the remove_html="1" attribute from whichever tag you end up using (but leave the encode_xml="1" attribute). You could also use remove_html="0" as Scott said - this has the same effect as removing the attribute.

Save the template, then rebuild.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.