Jump to:

22993 Posts in 11595 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » XML Parsing Error

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2380 Views
  • Tigermoon85
    Avatar
    Community Member
    6 Posts

    XML Parsing Error Link to this post

    Hi,
    I use firefox, then is error,

    XML Parsing Error: not well-formed
    Location: http://localhost/nhp_vn/tin-nhp/
    Line Number 71, Column 70:                  
    <td style="font-weight:bold;"><a href="tin-nhp/?newsID=9&offset=1">Test News</a></td>
    -------------------------------------------------------------------------------------^

    But when using IE will not error happen.
    Help me!

  • Tigermoon85
    Avatar
    Community Member
    6 Posts

    Re: XML Parsing Error Link to this post

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: XML Parsing Error Link to this post

    Just a guess, could it be that the & in the href should be &amp;?

    i.e:

    <a href="tin-nhp/?newsID=9&amp;offset=1">

  • Tigermoon85
    Avatar
    Community Member
    6 Posts

    Re: XML Parsing Error Link to this post

    Thanks , done.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: XML Parsing Error Link to this post

    Remove the XML header <?xml version="1.0" encoding="UTF-8"?> from your template.
    It can break a lot of stuff, namely:
    - You will get an XML error every time you enter an & or sometimes " in the CMS (for example as Page-Title)... unless you escape values properly in the template. It should be $Title.XML for regular usage and $Title.ATT for attributes.
    - JavaScript that rely on document.write won't work. Example: Google Analytics default integration.
    - JavaScript must be wrapped in a <![CDATA[ ]]> block.

    So most of the time it's a better idea to get rid of the XML header.

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: XML Parsing Error Link to this post

    Won't it break html validation if you leave out the XML header?

    I don't think it's a good idea to remove it. To me it's like having a warning system, and rather than addressing the issues that are causing the warnings, you are turning off the warning system.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: XML Parsing Error Link to this post

    No, it won't break HTML Validation. Your pages will still be valid XHTML, but just aren't parsed by the browser to be strictly XML compliant (which is another thing than XHTML). Also, XML documents have some restrictions in combination with JavaScript. This includes document.write and some jQuery functionality and plugins.
    I used to think the same way as you do, but the XML header causes so many problems, it's just not worth it to go and fix stuff for this (I'm talking about code written by third parties like jQuery plugins, that work perfectly fine without the XML header).

    Update: You don't need the "warning" system you speak of, validation covers that already (eg. an unescaped ampersand also fails validation).

    Update 2: FYI: Here's an example of a native jQuery function that doesn't work with an XML document: http://api.jquery.com/html
    Plugins relying on this function will fail.. not sure if there are other functions like this, but it's possible...

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: XML Parsing Error Link to this post

    Interesting stuff. Cheers for all the info.

    2380 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.