Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

XML Parsing Error


Go to End


9 Posts   4437 Views

Avatar
Tigermoon85

Community Member, 6 Posts

28 April 2010 at 4:12pm

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!

Avatar
Tigermoon85

Community Member, 6 Posts

28 April 2010 at 4:32pm

:(

Avatar
3dgoo

Community Member, 135 Posts

28 April 2010 at 4:59pm

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">

Avatar
Tigermoon85

Community Member, 6 Posts

28 April 2010 at 6:54pm

Thanks :), done.

Avatar
bummzack

Community Member, 904 Posts

28 April 2010 at 7:19pm

Edited: 28/04/2010 7:20pm

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.

Avatar
3dgoo

Community Member, 135 Posts

28 April 2010 at 8:33pm

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.

Avatar
bummzack

Community Member, 904 Posts

28 April 2010 at 9:46pm

Edited: 28/04/2010 9:54pm

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...

Avatar
3dgoo

Community Member, 135 Posts

29 April 2010 at 11:42am

Interesting stuff. Cheers for all the info.

Go to Top