Not to worry. Both cases have some form of architecture which makes it possible. But we don't want repeating, obfuscating code. And we don't want browser-detects. Here is the deal:
Your code is really great and helpful !
I tried this and it didn't work as an object (I kept getting ...not supported), so I converted it to a simple function. It works with Internet Explorer, but it hangs up in Firefox on xmldata.open... and I assume it's (at least partially) because encodeURIComponent is undefined. Please send me the code for that function and/or change this page to include it. This was the only thing I could find on the internet that addresses this subject (thanks very much), but it is useless without this missing piece because I still can't get the functionality in FireFox browser. Thanks.
By Aaron Meyer (not verified) at Wed, 20/06/2007 - 3:03pm | reply
This is not needed in Firefox, since it already has the DOMParser function. That is why I stated that this was available on Gecko-based browsers. Hence the if(typeof(DOMParser) == 'undefined'), which makes sure that DOMParser only gets defined when it is not yet defined. In Firefox it is, so changes are that you are replacing it. Don't :-)
The resulting "thing" should be a function, not an object. I tested this over and over, and when you place the code unaltered in the top of your page, virtually every browser that supports JavaScrip will work with it.
Example of use:
doc is then a reference to a DOM-object, containing the parsed XML.