Chapter 8. Handling XML in Ajax Applications

<feature><title>In This Chapter</title> <objective>

Understanding basic XML

</objective>
<objective>

Navigating XML documents using JavaScript

</objective>
<objective>

Grabbing XML elements en masse

</objective>
<objective>

Extracting the values of XML attributes

</objective>
<objective>

Validating the XML you get from the server

</objective>
</feature>

“Hm,” says the crack Ajax programmer. “I need some help.”

“Glad to be of service,” you say. “What can I help you with?”

“I’ve got my XML from the server okay, but now I can’t deal with it. How the heck do I navigate from element to element? How do I get the data I need out of this XML?”

“No problem,” you say. “Just read this chapter.” And you present the surprised Ajax programmer with your bill.

Ajax is all about getting data — often XML data — from the server. How do you handle that XML back in the browser? JavaScript has some strong XML-handling capabilities, as you discover in this chapter. Knowing how to work with XML in JavaScript is essential for any Ajax programmer because the server sends you XML, and you need to know how to extract data from that XML.

Understanding Basic XML

To work with XML in Ajax, you need to understand a few basics about the language and how it works. One key feature of XML is that you’re not restricted to a pre-determined set of tags, as in languages like HTML. You can create your own. In addition to tags, you also need to understand what makes an XML document well-formed ...

Get Ajax For Dummies® 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.