I have a project where I want to treat XHTML as XML. Which should be trivial because XHTML is XML – and it is trivial with FireFox.
However I have been experimenting with Microsoft Expression Web as my primary HTML/CSS editor – simply because of its awesome CSS re-factoring ability.
However I have run into an issue.
For XHTML to be parseable as XML with the browser XmlDocument/Msxml2.DOMDocument object, I need the XML to be well formed. From experiment it looks like with IE I need to include the xml prolog xml-declaration <?xml version=”1.0″ … ?> directive at the start before the DOCTYPE or any processing instruction or the document does not parse.
According to the W3 XML Spec – the xml prolog should be optional, and if this worked in practice then I would have no issue – but it seems that the IE Msxml2.DOMDocument object will not load XML if you don’t have the xml prolog xml-declaration before the DOCTYPE.
So I am forced to add it. And according to the XML spec that’s not only just fine, its recommended.


http://www.w3.org/TR/xhtml1/#docconf
But If I do that – in Microsoft Expression Web I get the following.

Its telling me I need to make my XHTML badly formed! I can only assume that despite having the perfectly legal xml prolog xml-declaration – its not recognising the DOCTYPE.
Could it be that the code to detect the DOCTYPE is not allowing for the xml prolog xml-declaration like it was with an previous issue in IE6?
Changing it to
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" ></meta>
Just seems to bring on another error.
It also forces me into IE6 rendering mode (Which I suspect is a kind of Quirks mode).
In that mode CSS does not work as expected.
If I remove the xml-declaration <?xml version=”1.0″ encoding=”UTF-8″?> then it works – but my XHTML is now not XML (according to Msxml2.DOMDocument ) and I can’t process it in any of the browsers XMLDocument objects without getting errors.
So I can’t use Expression Web to edit any of my XHTML.
If I can’t find a fix for this (or an explanation as to what I am doing wrong), I’m going to have to revert back to using FireFox and Firebug for all my CSS work.
I’m going to attack this from the angle of getting the Msxml2.DOMDocument in IE to parse the XML with the DOCTYPE at the start (no xml-declaration) – perhaps there is a workaround there.
It seems to work fine in FireFox.
Perplexed.