如何在所有浏览器中读取xml命名空间 [英] How to read xml namespace in all browsers

查看:50
本文介绍了如何在所有浏览器中读取xml命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Developers,



我在所有浏览器中使用java脚本读取XML文件时遇到问题。

我的代码如下在Firefox和IE中正常工作,但在Chrome和Opera中无效。



Hello Developers,

I am having a problem in reading XML file with java script in all browsers.
My code below is working fine in Firefox and IE but not working in Chrome and Opera.

function ReadXML(XML)
{
    var StudName = XML.getElementsByTagName("a:StudName");
        var ThumbImageURL = XML.getElementsByTagName("a:ThumbImageURL");
}







我使用getElementsByTagName读取XML命名空间在IE和Firefox中工作得很好但是它不适用于Chrome和Opera。



请帮我在所有浏览器中阅读XML命名空间。



你们是我唯一希望这样做的原因因为我在过去的3天里遇到了这个问题,我搜索了很多但没有做到这一点。

请帮助我...




I used getElementsByTagName to read XML namespace works fine in IE and Firefox but its not working in Chrome and Opera.

Please help me to read XML namespace in all browser.

You guys are my only hope to do this because i m facing this problem since last 3 days, i searched a lot but fail to do this.
please help me...

推荐答案

使用以下方法解决此问题,

以下代码将在所有现代浏览器中运行。



Use the following to solve this problem,
following code will run in all the modern browser.

function ReadXML(XML)
{
    var StudName = XML.getElementsByTagNameNS ? XML.getElementsByTagNameNS("*", "StudName") : XML.getElementsByTagName("a:StudName");

        var ThumbImageURL = XML.getElementsByTagNameNS ? XML.getElementsByTagNameNS("*", "ThumbImageURL") : XML.getElementsByTagName("a:ThumbImageURL");
}





使用这些变量来填充html或绑定控件。



享受脚本编制......



use these variables to fill html or bind control.

enjoy scripting...


这篇关于如何在所有浏览器中读取xml命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆