browser bug

I had a frustrating day at work today, writing javascript to do fancy things with XML documents and running into annoying bugs with various web browsers. I’ve come to expect bugs in Internet Explorer, but I was surprised today to find a bug in Opera’s implementation of the LSSerializer interface.

Considering that Opera seems to be the only browser to have implemented the LSSerializer interface, it’s a shame that they haven’t quite got it right. I’ve reported the bug to them so, hopefully, they’ll sort it out in the next point release.

For those interested in such things, I have documented the bug along with a demonstration of the problem. Obviously, the demonstration will only work for you if you are using Opera, but you can always look at the source code to see what’s going on.

There are 2 responses to “browser bug”:

  1. White Lynx says:

    Note that XML declaration is not a processing instruction (also syntax is similar, that makes existing terminology a little bit confusing), and is not treated as such (there are readonly attributes document.xmlEncoding, document.xmlVersion and document.xmlStandalone that can be used to retreive necessary info however), therefore
    [code]document.insertBefore(document.createProcessingInstruction(”xml”,”version=’1.0′ encoding=’utf-8′”), document.firstChild);[/code]
    will be processed as unknown PI, nor XML decraration.

  2. Richard says:

    Ah, I see what you mean. I always assumed that the xml declaration was itself a processing instruction, as the syntax is so similar.

    I found that when I was creating xml documents in javascript, using:

    document.implementation.createDocument() or, in IE, the Microsoft.XMLDOM activeX object

    The documents didn’t include an xml declaration. The only way I found to add the correct xml declaration was by using “document.createProcessingInstruction()”. Do you know of another way to ensure that xml documents contain the correct xml declaration?

Leave a Reply