FF怎么解析XML
时间:2005-11-17
来源:互联网
IE下用 Microsoft.XMLFOM
FireFox下面呢
FireFox下面呢
作者: fkiori 发布时间: 2005-11-17
<html>
<head>
<script type="text/javascript">
var xmlhttp
function loadXMLDoc(url)
{
// code for Mozilla, etc .FireFox也包括在其中了吧。。。
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET",url,true)
xmlhttp.send(null)
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
if (xmlhttp)
{
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET",url,true)
xmlhttp.send()
}
}
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
alert("XML data OK")
document.getElementById('A1').innerHTML=xmlhttp.status
document.getElementById('A2').innerHTML=xmlhttp.statusText
document.getElementById('A3').innerHTML=xmlhttp.responseText
}
else
{
alert("Problem retrieving XML data:" + xmlhttp.statusText)
}
}
}
</script>
</head>
<body onload="loadXMLDoc('note.xml')">
<h2>Using the HttpRequest Object</h2>
<p><b>status:</b>
<span id="A1"></span>
</p>
<p><b>status text:</b>
<span id="A2"></span>
</p>
<p><b>response:</b>
<br><span id="A3"></span>
</p>
</body>
</html>
<head>
<script type="text/javascript">
var xmlhttp
function loadXMLDoc(url)
{
// code for Mozilla, etc .FireFox也包括在其中了吧。。。
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET",url,true)
xmlhttp.send(null)
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
if (xmlhttp)
{
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET",url,true)
xmlhttp.send()
}
}
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
alert("XML data OK")
document.getElementById('A1').innerHTML=xmlhttp.status
document.getElementById('A2').innerHTML=xmlhttp.statusText
document.getElementById('A3').innerHTML=xmlhttp.responseText
}
else
{
alert("Problem retrieving XML data:" + xmlhttp.statusText)
}
}
}
</script>
</head>
<body onload="loadXMLDoc('note.xml')">
<h2>Using the HttpRequest Object</h2>
<p><b>status:</b>
<span id="A1"></span>
</p>
<p><b>status text:</b>
<span id="A2"></span>
</p>
<p><b>response:</b>
<br><span id="A3"></span>
</p>
</body>
</html>
作者: 单身 发布时间: 2005-11-19
xmlhttp=new XMLHttpRequest()
作者: 单身 发布时间: 2005-11-19
打错了,欧要得是可以代替 Microsoft.XMLDOM的东西
不是 Microsoft.XMLHTTP
不是 Microsoft.XMLHTTP
作者: fkiori 发布时间: 2005-11-21
XML Parser in Mozilla(firefox) Browsers
Plain XML documents are displayed in a tree-like structure in Mozilla (just like IE).
Mozilla also supports parsing of XML data using JavaScript. The parsed data can be displayed as HTML.
To create an instance of the XML parser with JavaScript in Mozilla browsers, use the following code:
var xmlDoc=document.implementation.createDocument("ns","root",null)
The first parameter, ns, defines the namespace used for the XML document. The second parameter, root, is the XML root element in the XML file. The third parameter, null, is always null because it is not implemented yet.
The following code loads an existing XML document ("note.xml") into Mozillas' XML parser:
<script type="text/javascript">
var xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("note.xml");
...
...
...
</script>
The first line of the script above creates an instance of the XML parser. The second line tells the parser to load an XML document called "note.xml".
Plain XML documents are displayed in a tree-like structure in Mozilla (just like IE).
Mozilla also supports parsing of XML data using JavaScript. The parsed data can be displayed as HTML.
To create an instance of the XML parser with JavaScript in Mozilla browsers, use the following code:
var xmlDoc=document.implementation.createDocument("ns","root",null)
The first parameter, ns, defines the namespace used for the XML document. The second parameter, root, is the XML root element in the XML file. The third parameter, null, is always null because it is not implemented yet.
The following code loads an existing XML document ("note.xml") into Mozillas' XML parser:
<script type="text/javascript">
var xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("note.xml");
...
...
...
</script>
The first line of the script above creates an instance of the XML parser. The second line tells the parser to load an XML document called "note.xml".
作者: 单身 发布时间: 2005-11-21
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28