ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Special Character Breaking the XML

July 08, 2009 9:22am

Subscribe [3]
  • #1 / Jul 08, 2009 9:22am

    Traverse

    66 posts

    Hello,
    I’m currently amending somebody else’s site and i’ve hit a problem I can’t solve.

    We’re using XML templates to publish information to Flash as well as HTML.  Unfortunately if an entry contains special characters (specifically @) the XML breaks and gives a “Not well formed error”.

    Any ideas how to fix this?

    Thanks

  • #2 / Jul 08, 2009 10:04am

    silenz

    1651 posts

    What about wrapping the fields with the XML Encode Plugin that comes with ExpressionEngine?

  • #3 / Jul 08, 2009 10:50am

    Ingmar

    29245 posts

    Traverse, does that help? Good advice there. The plugin is here.

  • #4 / Jul 09, 2009 1:21pm

    Traverse

    66 posts

    Sorry for the delay…

    I’ve put the xml_encode into the template and it parses.  Unortunately at the front end it gives a load of code instead of the email address I need to show.

    All this is about a simple @ symbol :(

    This is my XML template code..

    <?xml version="1.0" encoding="utf-8"?>
    <news>
        {exp:weblog:entries weblog="news" orderby="date" sort="desc" limit="10" disable="comments|member_data|trackbacks"}
          <comment title="{news_title}" news_copy="{if news_img}<a href="{news_img}qnEoPUaB4eX8C7olTZ5hU43otd5gaUHGtypography_img_src_endalign={news_img-align} ">{news_img}qnEoPUaB4eX8C7olTZ5hU43otd5gaUHGtypography_img_src_endalign={news_img-align} </a>{/if} {exp:xml_encode}{news_copy}{/exp:xml_encode}" news_link="{news_link}" news_date="{news_date}"></comment>
        {/exp:weblog:entries}
    
    {exp:weblog:entries weblog="news_panel" orderby="date" sort="desc" limit="10" disable="comments|member_data|trackbacks"}
          {exp:xml_encode}<bodyTxt copy="{news_panel}"></bodyTxt>{/exp:xml_encode}
        {/exp:weblog:entries}
    </news>

    Am I even doing this right?

  • #5 / Jul 09, 2009 3:52pm

    Ingmar

    29245 posts

    What exactly does “a lot of code” mean? Do you’ve got a link? Also, what version and build of EE are you using?

  • #6 / Jul 15, 2009 6:49am

    Traverse

    66 posts

    Hi Ingmar?  Did you get my message regarding your questions?  I sent you login details etc…


    After some experimenting i’ve found the problem is when EE tries to automatically turn email addresses into links.  I disabled this option in the admin and the XML parsed no problems…. brilliant… EXCEPT when I added the Blah link into the entry manually it broke the XML again in the same way?

    Unfortunately this problem is still an issue and I can’t find a solution :(

    Thanks

  • #7 / Jul 15, 2009 7:41am

    Traverse

    66 posts

    Still experimenting… added the XML encode to the XML template and the @ character is parsed but the the email is NOT displayed as a link.  When I re-enable EE auto turn emails into links feature it breaks again and displays the following code on the page.

    //= 0; i=i-1){ 
    if (l[i].substring(0, 1) == ' ') output += "&#"+unescape(l[i].substring(1))+";"; 
    else output += unescape(l[i]);
    }
    document.getElementById('eeEncEmail_JqO8ayzwus')[removed] = output;
    //]]>


    I’ve also tried converting all HTML into character entities but it then still doesn’t render as a link.

  • #8 / Jul 15, 2009 7:50pm

    Greg Aker

    6022 posts

    Turn off auto-generated URLs at:  CP Home ›  Admin ›  Weblog Administration ›  Weblog Management ›  Edit Weblog Preferences -> Weblog Posting Preferences and you should be in good shape.

    -greg

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases