admin管理员组

文章数量:1334954

I have some XML files which are currently used to load data into Adobe Flex applications. I am trying to make an HTML5 version of the application, and I need to load this same data into the html "app" so I can use and manipulate like I would in Flex. I have searched and can't find any information or examples on how to do this, or even if it can be done.

For example, if my application is a quiz, I have the questions, choices, and correct answers in an XML file. I would like the HTML file to load this data so it can display my quiz and I can use JS and jQuery to show one question at a time. I just don't know how to "get" the xml file. I suppose I could also convert the xml to json if need be, but it would be easier to use the xml as is.

I have some XML files which are currently used to load data into Adobe Flex applications. I am trying to make an HTML5 version of the application, and I need to load this same data into the html "app" so I can use and manipulate like I would in Flex. I have searched and can't find any information or examples on how to do this, or even if it can be done.

For example, if my application is a quiz, I have the questions, choices, and correct answers in an XML file. I would like the HTML file to load this data so it can display my quiz and I can use JS and jQuery to show one question at a time. I just don't know how to "get" the xml file. I suppose I could also convert the xml to json if need be, but it would be easier to use the xml as is.

Share Improve this question edited Nov 22, 2010 at 19:15 Steve asked Nov 22, 2010 at 19:10 SteveSteve 14.9k37 gold badges138 silver badges245 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

You can do that by using Ajax and a Javascript XML parser. The best way to do that is with a JS library, like jQuery.

Check out jQuery ajax to grab your XML: http://api.jquery./jQuery.ajax/

jParse is a pretty decent xml parser: http://jparse.kylerush/

Ajax is for accessing pages in the same domain. If you need to grab a file on a different domain you'll have to find a different solution.

本文标签: javascriptConsume data from XML file in an HTML5 applicationStack Overflow