Parsing Server Data
Now that we have data from the server, we need to find the exact information we need and make sure that it is in a format that our Ajax application can use. To do that, we’ll first need to examine the information. Because the data is a nicely structured XML document, our script walks the XML document tree to find and extract the particular data we need and store it in variables. Then, if needed, the script can reformat the data for later use.
The HTML and CSS that are in Scripts 13.5 and 13.6 couldn’t be much simpler, so we’re only going to look at the code in the JavaScript file, Script 13.7. For this task, the XML file is data about photographs stored on Flickr; a portion of the XML can be seen in Script 13.8.
To parse ...
Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.