Google Spreadsheet IMPORTHTML importing Null
Google Spreadsheet IMPORTHTML importing Null
我有一个从XML URL中提取数据的html文件。
当我通过浏览器浏览html时,我可以看到它加载了表中的数据。
然而,它在GoogleSpread中拉NULL
。
无论出于何种原因,都无法直接从Google电子表格中提取XML中的数据。我必须从我的网络服务器中提取它,然后将其拉到Google电子表格。
这是 html 代码:
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse:collapse;
}
th, td {
padding: 5px;
}
</style>
</head>
<body onload="loadXMLDoc()">
<table>
<tr>
<td>2</td>
<td id="demo"></td>
</tr>
</table>
<button type="button" onclick="loadXMLDoc()">Get my CD collection</button>
<script>
function loadXMLDoc() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myFunction(xmlhttp);
}
};
xmlhttp.open("GET", "http://www.w3schools.com/xml/cd_catalog.xml", true);
xmlhttp.send();
}
function myFunction(xml) {
var i;
var xmlDoc = xml.responseXML;
var table="<tr><th>Artist</th><th>Title</th></tr>";
var x = xmlDoc.getElementsByTagName("CD");
for (i = 0; i <x.length; i++) {
table += "<tr><td>" +
x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
"</td><td>" +
x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
"</td></tr>";
}
document.getElementById("demo").innerHTML = table;
}
</script>
</body>
</html>
以下是谷歌电子表格公式:
=IMPORTHTML("http://example.com/xml/myscript.html","table",1)
原因是因为它正在进行 ajax 调用 - 例如,您显示的"示例"xml 实际上是在调用"http://www.w3schools.com/xml/cd_catalog.xml",因此这是包含实际数据的 URL。
您可以使用
=IMPORTXML("http://www.w3schools.com/xml/cd_catalog.xml","//CD")
相关文章:
- 数组在递归方法中设置为null
- 字符串在将其传递给另一个活动Android JavaScript时读取Null
- 无法获取属性'selectedIndex'的未定义引用或null引用
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- 来自文本输入null的html javascript变量
- delete在Object上效率低下,但在DOM Element's的数据属性,与null out相比
- php代码在textbox更改事件上显示null
- 相同的RegExp返回不同的结果-第一次是正确的结果,第二次是null
- 在php中提交数据时,如果某些值为null,而某些值为非null,如何进行查询
- 未捕获的类型错误:无法读取属性'addEventListener'的null chrome扩展名
- 为什么localStorage[“..”]未定义,而localStorage.getItem(“..”)为null
- ajax在输入等于null时进行检查
- html+javascript:如何在某些条件下禁用dropdownlist中的null选项
- 未捕获的类型错误:无法读取属性'状态'在react中为null
- contentWindow.document.body is null
- 在经过DATE验证的列中创建null值
- 为什么是文档.旧版应用程序中的DOM-object.properties为null
- if(foo!==null)的计算结果为true,即使foo为null
- php函数的ajax html$_POST值返回null
- Google Spreadsheet IMPORTHTML importing Null