Results 1 to 6 of 6

Thread: Creating line break in xml for RSS feed

  1. #1
    Join Date
    Mar 2009

    Question Creating line break in xml for RSS feed


    I am new to xml and my issue pertains to an RSS feed that I am passing in an xml file.

    The RSS feed http://feeds2.feedburner.com/quotesandpoem/poemoftheday
    displays a poem every day.

    The issue that I have is that I cannot figure out how to create new
    lines for each line of my poem. The entire poem text is garbled into
    a single line in the feed.

    The poem text is under the xml tag <description> as follows:
    <description> poem text </description>. If I put any of the typical html tags in there to create the new line it does not work. And I am not sure what xml tags I should use so that the poem is formatted in multiple lines based on the poem text flow.

    The code template for the xml fed to RSS feed is as follows:

    <?xml version="1.0" encoding="windows-1252"?>
    <rss version="2.0">
    <title>title text </title>
    <link>link text</link>
    <description> Description Text</description>
    <copyright>Quotes And Poem (c) 2004 - 2007</copyright>
    <title>Poem Title</title>
    <link>Poem Link</link>
    <pubDate> Publication Date </pubDate>
    <guid isPermaLink="true">Text here</guid>

    I appreciate any help in resolving this issu.

  2. #2
    Join Date
    Aug 2006
    Have you tried it like this:

    <p>There once was a man from nantucket<br>
    Who kept all his fish in a bucket</p>

  3. #3
    Join Date
    May 2008
    Using CDATA still won't preserve line breaks, and not all RSS aggregators understand XHTML elements like p and br.

    Try using @xml:space with a value of "preserve":
    <description xml:space="preserve">
    From section 2.10 (white-space handling) of the XML recommendation:
    In editing XML documents, it is often convenient to use "white space" (spaces, tabs, and blank lines) to set apart the markup for greater readability. Such white space is typically not intended for inclusion in the delivered version of the document. On the other hand, "significant" white space that should be preserved in the delivered version is common, for example in poetry and source code.


    A special attribute named xml:space may be attached to an element to signal an intention that in that element, white space should be preserved by applications. In valid documents, this attribute, like any other, MUST be declared if it is used. When declared, it MUST be given as an enumerated type whose values are one or both of "default" and "preserve".

  4. #4
    Join Date
    Mar 2009
    Thanks for the replies,

    rpgfan3233 I tried your method, but there must be something that I missed as the RSS feed gave me an error.

    What I tried (along with a few different permutations) was :

    <description xml:space="preserve">
    He put the belt around my life, -- <br>
    heard the buckle snap... <br>
    .......text continues....

    The error given was along the line that br did not match </description> tag

  5. #5
    Join Date
    May 2008
    You shouldn't need a <br> when you use xml:space, and <br> is HTML anyway.

    You would need to use the XHTML version <br/> if you want it to be parsed properly. On the other hand, <br/> might not work anyway. As I mentioned, XHTML isn't recognized by all RSS aggregators, even if you qualify it with the proper namespace. Take out the <br> tags and see if xml:space fixed your issue. If it didn't, I suppose you could try using <br/>, though it technically wouldn't be "valid" RSS, and not all aggregators will understand what to do with it (some will even fail to parse the feed since <br/> is unrecognised).

  6. #6
    Join Date
    Mar 2009
    Hi rpgfan,

    I tried <description xml:space="preserve"> in multiple ways including no html tag, <br>, <br />, etc - but with no luck.

    However, I tried the CDATA that tracknut mentioned and it appears to work its magic - atleast with google reader, my yahoo and feedburner.


    Thanks to both of you in providing valuable suggestions.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.09415 seconds
  • Memory Usage 2,886KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates