Solution to XML namespace problem in getElementsByTagName
Here is a simple code I used as a solution to XML namespace handling in different browsers(IE, Firefox 2, Firefox3, ..). But it requires more arguments like namespace and namespace frefix. But I think that this function can be improve based on problem that you have to solve.1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function getElementsByTagName(tagName, ns, prefix, scope){ var elementListForReturn = scope.getElementsByTagName(prefix+":"+tagName); if(elementListForReturn.length == 0){ elementListForReturn = scope.getElementsByTagName(tagName); if(elementListForReturn.length == 0){ elementListForReturn = scope.getElementsByTagName("ns:"+tagName); if(elementListForReturn.length == 0 && document.getElementsByTagNameNS){ elementListForReturn = scope.getElementsByTagNameNS(ns, tagName); } } } return elementListForReturn; } |
Related posts brought to you by Yet Another Related Posts Plugin.



It seems nice but can you please give any example to use this function.
Thanks so much for the code. I had been struggling to get this slideshow from an RSS feed to work in IE, but the namespaces had me stumped. http://www.plaidhandprint.com/myshow.php?Deviant=flowersdaughter