[英]How to read and parse (local) XML-file in Prototype JS?
I have to create a module in a specific project, which already uses PrototypeJS. 我必须在已经使用PrototypeJS的特定项目中创建一个模块。
What I have: - An XML File with information 我所拥有的:-具有信息的XML文件
What I want: - A simple div, which displays the (with XPath filterd) Content of the XML-File. 我想要的是:-一个简单的div,它显示XML文件的内容(使用XPath过滤)。
I am complete new to PrototypeJS and dont know where to begin, so I appreciate your help. 我是PrototypeJS的新手,也不知道从哪里开始,所以感谢您的帮助。
Blessing chris 克里斯祝福
If by "local" you mean "client-side", you will have to : 如果“本地”是指“客户端”,则必须:
edit: to clarify the fetch part, here is how you can do it using Prototype: 编辑:澄清获取部分,这是您可以使用原型进行的操作:
new Ajax.Request('myfile.xml', {
onSuccess: function(transport) {
myParseXml(transport.responseXML);
},
onFailure: function(transport) {
alert('Failure! Status code '+transport.status+' ('+transport.statusText+')');
}
);
function myParseXml(xmlDoc) {
var root = xmlDoc.documentElement;
...
}
Try: 尝试:
<xml src="MyData.xml" id="mydata" >
var mydata = document.getElementById('mydata');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.