cross-browser 'getElementsByTagName' with namespace from responseXML

独自空忆成欢 提交于 2019-12-05 07:00:46

This is what I use:

function byTagNS(xml,tag,ns) {
    return xml.getElementsByTagNameNS
      ? xml.getElementsByTagNameNS(ns,tag)
      : xml.getElementsByTagName(ns+":"+tag);
}

With in your case:

byTagNS(responseXML, "row", "z")

If you don't care about the namespace then you could use the following:

xml.getElementsByTagNameNS("*", "yourElementHere")

This will fetch any element with the desired name regardless of which namespace it has or whether it has any namespace at all. Additionally, this should work as expected across different browsers.

See link for documentation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!