如何把 XML 文件显示为 HTML 表格
来源:互联网 发布:淘宝原创品牌 知乎 编辑:程序博客网 时间:2024/06/06 05:28
<html>
<head>
<script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Mozilla, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5, IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=onResponse;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function onResponse()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
{
alert("Problem retrieving XML data");
return;
}
txt="<table border='1'>";
x=xmlhttp.responseXML.documentElement.getElementsByTagName("CD");
for (i=0;i<x.length;i++)
{
txt=txt + "<tr>";
xx=x[i].getElementsByTagName("TITLE");
{
try
{
txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er)
{
txt=txt + "<td> </td>";
}
}
xx=x[i].getElementsByTagName("ARTIST");
{
try
{
txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er)
{
txt=txt + "<td> </td>";
}
}
txt=txt + "</tr>";
}
txt=txt + "</table>";
document.getElementById('copy').innerHTML=txt;
}
</script>
</head>
<body>
<div id="copy">
<button onclick="loadXMLDoc('/example/xmle/cd_catalog.xml')">Get CD info</button>
</div>
</body>
</html>
<!--该代码片段来自于: http://www.sharejs.com/codes/html/9064-->
如何把 XML 文件显示为 HTML 表格
http://www.sharejs.com/codes/html/9064
<html>
<head>
<script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Mozilla, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5, IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=onResponse;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function onResponse()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
{
alert("Problem retrieving XML data");
return;
}
txt="<table border='1'>";
x=xmlhttp.responseXML.documentElement.getElementsByTagName("CD");
for (i=0;i<x.length;i++)
{
txt=txt + "<tr>";
xx=x[i].getElementsByTagName("TITLE");
{
try
{
txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er)
{
txt=txt + "<td> </td>";
}
}
xx=x[i].getElementsByTagName("ARTIST");
{
try
{
txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er)
{
txt=txt + "<td> </td>";
}
}
txt=txt + "</tr>";
}
txt=txt + "</table>";
document.getElementById('copy').innerHTML=txt;
}
</script>
</head>
<body>
<div id="copy">
<button onclick="loadXMLDoc('/example/xmle/cd_catalog.xml')">Get CD info</button>
</div>
</body>
</html>
<!--该代码片段来自于: http://www.sharejs.com/codes/html/9064-->
如何把 XML 文件显示为 HTML 表格
http://www.sharejs.com/codes/html/9064
- 如何把 XML 文件显示为 HTML 表格
- 如何把ini文件转换为xml
- 如何把DataSet保存为XML文件
- 如何把DataSet保存为XML文件
- 查看如何在一个 HTML 表格中显示 XML 数据。
- AJAX编程技巧:在页面上中如何将受到的xml文件显示为表格的形式?
- AJAX编程技巧:在页面上中如何将收到的xml文件显示为表格的形式?
- 把HTML无嵌套表格完美导出为Excel文件的方法
- [转贴]把HTML无嵌套表格完美导出为Excel文件的方法
- 把HTML无嵌套表格完美导出为Excel文件的方法
- 如何把Excel表格数据转成XML
- 在 HTML 表格中显示 XML 数据
- 把xml数据绑定到html表格中
- 把xml数据绑定到html表格中
- 把mysql的数据表格输出为html
- blog 如何把html转化为jsp
- 如何把html转化为图象
- 网站开发进阶(二十五)js如何将html表格导出为excel文件
- 烦人的幻灯片(拓扑 很烦人)
- [leetCode刷题笔记]2017.02.09
- 面向对象-接口
- Tomact和MySql搭建android简单服务器
- 不使用第三方变量,交换两个变量的值 ,并且适度考虑范围溢出(20多亿)
- 如何把 XML 文件显示为 HTML 表格
- 给编程生涯充电的 10 本书
- Java 8十个lambda表达式案例
- Delphi ListView基本用法大全
- ubuntu创建U盘启动盘
- WebApi 4大方法初探 get、post、put、delete
- DOM 节点关系
- Android中USB打印机无法创建/dev/usb/lp0节点
- iOS使用imageIO完成渐进加载图片