O'Reilly logo

Ajax Bible by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9

XML and Ajax

IN THIS CHAPTER

  • Working with XML in JavaScript
  • Navigating through XML documents
  • Retrieving XML element data
  • Retrieving XML element attribute data
  • Validating downloaded XML data

As you may remember from Chapter 1, Ajax stands for Asynchronous JavaScript and XML. This chapter is on the XML part of Ajax. Handling XML in a browser using JavaScript is far from intuitive, and this chapter covers the details — which you're going to need to know if you download XML from the server.

JavaScript has some great XML-handling functions built in, but they're not much use unless you know how to use them, and how XML is treated in the browser. But don't worry: you'll get the expertise you need here.

Creating XML

The name of the game in XML is data storage, and that's what XML excels at. XML got to be so popular because it's a text-based way of storing your data, and the Internet is based on text transfer. So XML became the Internet's way of slinging data around, as you already know now that you're an Ajax developer.

When you create an XML document, you also create the tags that go into that document. Unlike HTML, XML has no set element tag names that you have to work with; you're free to create your own tags and structure your data as you like. However, there are a number of rules to creating XML, and you'll see the most important ones here.

images For the full XML story, take ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required