Tom Morris



2007.10.23

  No. 690 

Solving MIME type headaches 2007-10-23T10:09:38ZPermalink

My site occasionally serves invalid XML. This is an unfortunate business. The reasons are quite convoluted, but are to do with the way that you can't use CDATA sections inside attributes (Kosso will understand what I'm talking about).

So sometimes unencoded stuff is sent to the browser, or, as this morning, an unclosed span element.

I decided to fix it by writing some code that would detect whether what's about to be sent is valid XML. Simple enough. Just load it all into a DOM tree, and if it chokes on loading, it's not valid XML - then serve it as text/html to invoke the usually slower XHTML parsers.

Here's the code. It's done with PHP output control and the DOM - so PHP5 only, folks. You do use PHP5, right?

Links from del.icio.us

Comments
blog comments powered by Disqus


Tom Morris 9f4907d871750fd4c9b9bad7086701b51d6abd10 bd9f81a05283ed85e699175ed057b4a497f20b77 802c68123e12bf69d99a25a87cef360f18813fe4
Currently in: East Sussex, England
Usually in: East Sussex, United Kingdom
AIM: tommorris
YIM: tom.morris

I am a , an , like to code in and (and Java, but let’s not talk about that), and noodle about with and the .

I have an MA in philosophy from Heythrop College, University of London. My philosophical interests are in analytic metaphysics, ontology, modality, the work of , , , and . I have a strange, unfulfilled interest in . I’ve been influenced by Gadamer, by , , and .

Musically, I like jazz fusion, soul and P-Funk. My musical nirvana would be a mixture of Beethoven, Miles Davis and George Clinton topped with a side-serving of Erykah, Jill and Angie.

I also write for the Citizendium, an online encyclopedia project. If you know about stuff, you should join in. I occasionally produce audio recordings for The Pod Delusion.

Elsewhere:

  • GPG Key
  • del.icio.us
  • Flickr
  • Twitter
  • Jaiku
  • LinkedIn
  • ma.gnolia
  • blip.tv
  • upcoming.org
  • MetaFilter
  • LiveJournal
  • CiteULike
  • Technorati Profile

RSS Feed Subscribe:

RDF

« October 2007 »
SuMoTuWeThFrSa
 123456
78910111213
14151617181920
21222324252627
28293031 

View in month context

On this day in: 2006 2008 2009