简体   繁体   English

如何解析XML文件并将其放入AIR中的JavaScript数组?

[英]How can I parse an XML file and put it into a JavaScript array in AIR?

I am currently doing an A level computing project, in which I need to parse XML and put the elements into an array. 我目前正在做一个A级计算项目,在该项目中,我需要解析XML并将元素放入数组中。 I am using JavaScript in Dreamweaver and the final application will be run in AIR. 我在Dreamweaver中使用JavaScript,最终的应用程序将在AIR中运行。 I am having a hard time understanding the code in this answer to another question: XML parsing of a variable string in JavaScript 我很难理解这个问题的答案中的代码: JavaScript中可变字符串的XML解析

How would I adapt that code to put an XML file chosen by the user into an array, and would it work in AIR? 我将如何修改该代码以将用户选择的XML文件放入数组中,并在AIR中工作?

This is the structure of the XML I want to use: 这是我要使用的XML的结构:

<node id="0">
 <nodetype>0</nodetype>
 <connectedto>2,3</connectedto>
 <distanceto>10,5</distanceto>
</node>

The structure of the array is: 数组的结构为:

Node | Type | ConnectedTo | DistanceTo
  1  |  0   |     2       |    10
  1  |  0   |     3       |     5

Thanks in advance for any help. 在此先感谢您的帮助。

AIR uses WebKit render engine, so you should stick to the webkit implementation details when parsing XML. AIR使用WebKit渲染引擎,因此在解析XML时,您应该坚持webkit的实现细节。 Here is the link to the explanation of the parsing and reading XML in Webkit. 这是对Webkit中解析和读取XML的解释的链接。

http://www.insideria.com/2008/04/adobe-air-webkit-and-xml.html http://www.insideria.com/2008/04/adobe-air-webkit-and-xml.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM