Javascript 无法读取属性';子节点';未定义但列表有效的

Javascript 无法读取属性';子节点';未定义但列表有效的,javascript,xml,xmlhttprequest,Javascript,Xml,Xmlhttprequest,我有以下代码,它应该从xml文件中的每个父节点返回两个子节点值 ADM资产可用性 var-xhttp; xhttp=newXMLHttpRequest(); xhttp.onreadystatechange=函数(){ if(this.readyState==4&&this.status==200){ 资产启用日期(本); } }; open(“GET”,“Assets.xml”,true); xhttp.send(); 函数AssetUpdate(xml){ 变量n,x,i,txt,xmlD

我有以下代码,它应该从xml文件中的每个父节点返回两个子节点值


ADM资产可用性
var-xhttp;
xhttp=newXMLHttpRequest();
xhttp.onreadystatechange=函数(){
if(this.readyState==4&&this.status==200){
资产启用日期(本);
}
};
open(“GET”,“Assets.xml”,true);
xhttp.send();
函数AssetUpdate(xml){
变量n,x,i,txt,xmlDoc;
xmlDoc=xml.responseXML;
txt=“”;
x=xmlDoc.getElementsByTagName(“资产”);
对于(i=0;i
txt2
返回请求的值,没有任何问题。但是,
txt4
(结构精确)会导致在的浏览器中检测到错误

未捕获的TypeError:无法读取AssetUpdate AssetPage上未定义的属性“childNodes”。php:33)

我尝试了大约30种代码、循环和标记名的变体,仍然导致了相同的错误

请帮忙

这是供参考的xml

<?xml version="1.0" ?><Assets>
<Asset>5
    <AssetID>1</AssetID>
    <AssetName>Laser</AssetName>
    <Live>Test</Live>
</Asset>
<Asset>7
    <AssetID>2</AssetID>
    <AssetName>Press</AssetName>
    <Live>Test1</Live>
</Asset>
<Asset>9
    <AssetID>3</AssetID>
    <AssetName>Fab</AssetName>
    <Live>Test2</Live>
</Asset>
<Asset>blue
    <AssetID>78</AssetID>
    <AssetName>Paint</AssetName>
    <Live>Test3</Live>
</Asset></Assets>
但没有犯该线程中识别的错误

编辑

Navigated to http://localhost/ADMApp/AssetPage.php 
AssetPage.php:24 Uncaught TypeError: Cannot read property 'responseXML' of undefined
at AssetUpdate (AssetPage.php:24)
at onload (AssetPage.php:6)
AssetUpdate @ AssetPage.php:24
onload @ AssetPage.php:6
AssetPage.php:34 HTMLCollection []length: 0__proto__: HTMLCollectionitem: ƒ 
item()arguments: (...)caller: (...)length: 1name: "item"__proto__: ƒ 
()apply: ƒ apply()arguments: (...)bind: ƒ bind()call: ƒ call()caller: 
(...)constructor: ƒ Function()length: 0name: ""toString: ƒ 
toString()Symbol(Symbol.hasInstance): ƒ [Symbol.hasInstance]()get arguments: 
ƒ ()set arguments: ƒ ()get caller: ƒ ()set caller: ƒ ()__proto__: 
Object[[FunctionLocation]]: <unknown>[[Scopes]]: Scopes[0][[Scopes]]: 
Scopes[0]length: (...)namedItem: ƒ namedItem()constructor: ƒ 
HTMLCollection()Symbol(Symbol.iterator): ƒ 
values()Symbol(Symbol.toStringTag): "HTMLCollection"get length: ƒ 
length()__proto__: Object
AssetPage.php:35 undefined
AssetPage.php:36 Uncaught TypeError: Cannot read property 'childNodes' of 
undefined
at AssetUpdate (AssetPage.php:36)
at XMLHttpRequest.xhttp.onreadystatechange (AssetPage.php:15)
AssetUpdate @ AssetPage.php:36
xhttp.onreadystatechange @ AssetPage.php:15
XMLHttpRequest.send (async)
(anonymous) @ AssetPage.php:19
AssetPage.php:19 XHR finished loading: GET 
"http://localhost/ADMApp/Assets.xml".
(anonymous) @ AssetPage.php:19
导航到http://localhost/ADMApp/AssetPage.php 
AssetPage.php:24未捕获类型错误:无法读取未定义的属性“responseXML”
在AssetUpdate(AssetPage.php:24)
加载时(AssetPage.php:6)
AssetUpdate@AssetPage.php:24
onload@AssetPage.php:6
php:34 HTMLCollection[]长度:0_uuproto_uu:HTMLCollectionitem:ƒ
item()参数:(…)调用方:(…)长度:1name:“item”uuuuuuuuuuuuuuu:ƒ
()应用:应用()参数:(…)绑定:绑定()调用:调用()调用方:
(…)构造函数:函数()长度:0name:“toString:ƒ”
toString()符号(Symbol.hasInstance):ƒ[Symbol.hasInstance]()获取参数:
ƒ()设置参数:ƒ()获取调用方:ƒ()设置调用方:ƒ()uuu proto_uu:
对象[[FunctionLocation]]:[[Scopes]]:作用域[0][[Scopes]]:
作用域[0]长度:(…)namedItem:ƒnamedItem()构造函数:ƒ
HTMLCollection()符号(Symbol.iterator):ƒ
values()符号(Symbol.toStringTag):“HTMLCollection”获取长度:ƒ
length()\uuuu proto\uuuu:对象
php:35未定义
AssetPage.php:36未捕获类型错误:无法读取的属性“childNodes”
未定义
在AssetUpdate(AssetPage.php:36)
位于XMLHttpRequest.xhttp.onreadystatechange(AssetPage.php:15)
AssetUpdate@AssetPage.php:36
xhttp.onreadystatechange@AssetPage.php:15
XMLHttpRequest.send(异步)
(匿名)@AssetPage.php:19
php:19 XHR已完成加载:GET
"http://localhost/ADMApp/Assets.xml".
(匿名)@AssetPage.php:19
我不知道有什么更好的方法来显示这个错误编码,所以如果这不正确,请告诉我(还有下面实际显示的图像)

如果您需要我完全扩展HTMLCollection,请告诉我,但这是一个非常大的级联


谢谢你迄今为止的帮助

好的,我仍然很感激其他的输入,但据我所知,除了在不同的计算机上运行它之外,我没有做任何更改。在另一台计算机上运行电脑后重新启动电脑,它也能正常工作。。。。 我的想法是,这是我的本地主机服务器在重启时自行解决的问题

谢谢
康纳

好的,我仍然很感激其他的输入,但据我所知,除了在不同的计算机上运行它,我什么都没做。在另一台计算机上运行电脑后重新启动电脑,它也能正常工作。。。。 我的想法是,这是我的本地主机服务器在重启时自行解决的问题

谢谢
Connor开始调试整个txt4,并将其一步一步地打印到控制台,如consloe.log(x[i]);log(x[i].getElementsByTagName(“Live”);consloe.log(x[i].getElementsByTagName(“Live”)[0]);等等,看看你能得到什么。@KataCsortos修复
consloe
console
@barbsan现在不能编辑我的上一条评论,但是是的,键入
console.log
而不是
consloe.log
嗨,谢谢你们的快速回复。我已经按照你的建议在日志中添加了内容,但我不能说我从中学到了什么。我将尽快用日志文件/pic或其他东西编辑主帖子。由于在原始帖子中可能不清楚,我还收到一个“未捕获的TypeError:无法读取未定义的属性'responseXML'的错误”。代码似乎总是生成此错误,但仍能正常工作。但是,当第二次调用时,这会导致第二个错误吗?开始调试并逐步将整个txt4打印到控制台,如consloe.log(x[i]);log(x[i].getElementsByTagName(“Live”);consloe.log(x[i].getElementsByTagName(“Live”)[0]);等等,看看你能得到什么。@KataCsortos修复
consloe
console
@barbsan现在不能编辑我的上一条评论,但是是的,键入
console.log
而不是
consloe.log
嗨,谢谢你们的快速回复。我已经按照你的建议在日志中添加了内容,但我不能说我从中学到了什么。我将尽快用日志文件/pic或其他东西编辑主帖子。由于在原始帖子中可能不清楚,我还收到一个“未捕获的TypeError:无法读取未定义的属性'responseXML'的错误”。代码似乎总是生成此错误,但仍能正常工作。但是,在第二次调用时,这会导致第二个错误吗?