Use data from XML file in HTML5 application?

I have some XML files that are currently used to load data into Adobe Flex applications. I'm trying to make a version of an HTML5 application, and I need to load the same data into an html application so that I can use and manipulate it like in Flex. I searched and cannot 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 questions, options, and the correct answers in an XML file. I would like the HTML file to load this data so that it can display my quiz, and I can use JS and jQuery to display one question at a time. I just don’t know how to β€œget” the xml file. I suppose that I could also convert xml to json if necessary, but it would be easier to use xml as is.

+4
source share
1 answer

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

Take a look at jQuery ajax to grab your XML: http://api.jquery.com/jQuery.ajax/

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

Ajax is designed to access pages in one domain. If you need to capture the file in another domain, you will have to find another solution.

+4
source

All Articles