简体   繁体   中英

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. I am using JavaScript in Dreamweaver and the final application will be run in AIR. I am having a hard time understanding the code in this answer to another question: XML parsing of a variable string in JavaScript

How would I adapt that code to put an XML file chosen by the user into an array, and would it work in AIR?

This is the structure of the XML I want to use:

<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. Here is the link to the explanation of the parsing and reading XML in Webkit.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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