- XML Reference Guide
- Overview
- What Is XML?
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Table of Contents
- The Document Object Model
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- DOM and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Implementations
- DOM and JavaScript
- Using a Repeater
- Repeaters and XML
- Repeater Resources
- DOM and .NET
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Downloads
- DOM and C++
- DOM and C++ Resources
- DOM and Perl
- DOM and Perl Resources
- DOM and PHP
- DOM and PHP Resources
- DOM Level 3
- DOM Level 3 Core
- DOM Level 3 Load and Save
- DOM Level 3 XPath
- DOM Level 3 Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- The Simple API for XML (SAX)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SAX and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- SAX and .NET
- Informit Articles and Sample Chapters
- SAX and Perl
- SAX and Perl Resources
- SAX and PHP
- SAX and PHP Resources
- Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Document Type Definitions (DTDs)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Schemas
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- RELAX NG
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Schematron
- Official Documentation and Implementations
- Validation in Applications
- Informit Articles and Sample Chapters
- Books and e-Books
- XSL Transformations (XSLT)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XSLT in Java
- Java in XSLT Resources
- XSLT and RSS in .NET
- XSLT and RSS in .NET Resources
- XSL-FO
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XPath
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Base
- Informit Articles and Sample Chapters
- Official Documentation
- XHTML
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XHTML 2.0
- Documentation
- Cascading Style Sheets
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XUL
- XUL References
- XML Events
- XML Events Resources
- XML Data Binding
- Informit Articles and Sample Chapters
- Books and e-Books
- Specifications
- Implementations
- XML and Databases
- Informit Articles and Sample Chapters
- Books and e-Books
- Online Resources
- Official Documentation
- SQL Server and FOR XML
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- Service Oriented Architecture
- Web Services
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Creating a Perl Web Service Client
- SOAP::Lite
- Amazon Web Services
- Creating the Movable Type Plug-in
- Perl, Amazon, and Movable Type Resources
- Apache Axis2
- REST
- REST Resources
- SOAP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SOAP and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- WSDL
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- UDDI
- UDDI Resources
- XML-RPC
- XML-RPC in PHP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Ajax
- Asynchronous Javascript
- Client-side XSLT
- SAJAX and PHP
- Ajax Resources
- JSON
- Ruby on Rails
- Creating Objects
- Ruby Basics: Arrays and Other Sundry Bits
- Ruby Basics: Iterators and Persistence
- Starting on the Rails
- Rails and Databases
- Rails: Ajax and Partials
- Rails Resources
- Web Services Security
- Web Services Security Resources
- SAML
- Informit Articles and Sample Chapters
- Books and e-Books
- Specification and Implementation
- XML Digital Signatures
- XML Digital Signatures Resources
- XML Key Management Services
- Resources for XML Key Management Services
- Internationalization
- Resources
- Grid Computing
- Grid Resources
- Web Services Resource Framework
- Web Services Resource Framework Resources
- WS-Addressing
- WS-Addressing Resources
- WS-Notifications
- New Languages: XML in Use
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Google Web Toolkit
- GWT Basic Interactivity
- Google Sitemaps
- Google Sitemaps Resources
- Accessibility
- Web Accessibility
- XML Accessibility
- Accessibility Resources
- The Semantic Web
- Defining a New Ontology
- OWL: Web Ontology Language
- Semantic Web Resources
- Google Base
- Microformats
- StructuredBlogging
- Live Clipboard
- WML
- XHTML-MP
- WML Resources
- Google Web Services
- Google Web Services API
- Google Web Services Resources
- The Yahoo! Web Services Interface
- Yahoo! Web Services and PHP
- Yahoo! Web Services Resources
- eBay REST API
- WordML
- WordML Part 2: Lists
- WordML Part 3: Tables
- WordML Resources
- DocBook
- Articles
- Books and e-Books
- Official Documentation and Implementations
- XML Query
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XForms
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Resource Description Framework (RDF)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Topic Maps
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation, Implementations, and Other Resources
- Rich Site Summary (RSS)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Simple Sharing Extensions (SSE)
- Atom
- Podcasting
- Podcasting Resources
- Scalable Vector Graphics (SVG)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- OPML
- OPML Resources
- Summary
- Projects
- JavaScript TimeTracker: JSON and PHP
- The Javascript Timetracker
- Refactoring to Javascript Objects
- Creating the Yahoo! Widget
- Web Mashup
- Google Maps
- Indeed Mashup
- Mashup Part 3: Putting It All Together
- Additional Resources
- Frequently Asked Questions About XML
- What's XML, and why should I use it?
- What's a well-formed document?
- What's the difference between XML and HTML?
- What's the difference between HTML and XHTML?
- Can I use XML in a browser?
- Should I use elements or attributes for my document?
- What's a namespace?
- Where can I get an XML parser?
- What's the difference between a well-formed document and a valid document?
- What's a validating parser?
- Should I use DOM or SAX for my application?
- How can I stop a SAX parser before it has parsed the entire document?
- 2005 Predictions
- 2006 Predictions
- Nick's Book Picks
Almost a decade ago, back when web-based applications were still finding their way, I found myself with a problem. I needed to update a shopping cart page with additional options and prices based on other choices the user had made. Because of customer-sensitive ordering and other factors, generating the changes locally within the browser was impossible; I'd simply have to make a call to the server for the information.
Back then I had a couple of choices. One option was to simply make the user submit the page, and then regenerate it with the correct information. Given that these were the days of dial-up and slow browsers, and that the page itself was very complex, this was not a very attractive option.
The second option was to make a call to the server from within the page. Back then, there was just one way to do it. I rigged up a Java applet that detected the information already in the form, and then used that information to make a call back to the server using an HTTP request. The server sent back a response, which the applet parsed and passed back to another form element using Javascript.
It was ugly, but it worked.
Today we wouldn't have to go through anywhere near as much trouble. Today, rather than wiring together applets and Javascript and waiting for the applet to download, we can simply do everything using Javascript. In fact, today we have the option to do much more, combining JavaScript, HTTP requests, CSS (including DOM-related technologies variously known as DHTML), and XSLT. It's being called a "new approach" to web development, but really, all that's new about it is the name: Ajax, or "Asynchronous JavaScript + XML".
Still, the "asynchronous" part is attractive, and it's making applications much more interactive; the user can simply go about his or her business exploring the page without having to wait for the network operation to finish first. Some good examples of this technique in action include:
-
Google Suggest
analyzes what you've entered as you type, looks up likely choices, and gives you a pull-down list, including the approximate
number of results. You then have the option to use your arrow keys to make a choice or to click on a choice.
-
Backbase includes a number of very cool demos, including a shopping site that displays category products and even
enables users to sort items via drag and drop.
-
Ripped Tickets not only tries to anticipate what you're going
to type, but actually looks up the data and displays it on the page as you type and refine your search.
-
Google Maps is, in some ways, the granddaddy of this
technique. Users enter an address and the map appears on the page. Users can also scroll the map, which tries to
pre-fetch likely areas. It also uses CSS to provide a pointer that includes a shadow on the actual map. You can also switch
back and forth between the map and the satellite image.
OK, so that's what we can do with it, now how does it work?
Let's take the example of Ripped Tickets to start with. I'm not privvy to the inner workings of the site, nor have I sat down and analyzed it -- though that's an option, since this is all in the browser, after all -- but here's how the basic process of using something like this could work:
- The page loads. Nothing out of the ordinary here.
- The user begins to type in the form box.
- The page detects the typing in the form box, either using an event based on the keypress or a timed polling process. (For example, checking the box every second rather than reacting to every keypress of a fast typist.)
- JavaScript on the page sends a request to the server with the information the user has already typed and specifies a function to handle the result whenever it comes back. This request is made via either the XMLHttpRequest object (in Mozilla and Safari) or the Microsoft.XMLHTTP ActiveX object (in Internet Explorer).
- The JavaScript returns control to the user, who's still free to type more and look around more.
- When the response comes back, the function receives it as, say, an XML document.
- The script uses XSLT to transform the XML document into the HTML that represents the table.
- The script uses the Document Object Model to get a reference to a
div
element below the search box. - The script uses the Document Object Model to replace the contents of that
div
with the new results. - The user sees results on the page.
Now, that may seem like a lot going on, but if you visit any of these sites, you'll see that it's not only simple for the user, but much, much, much less disruptive than the old type-submit-wait-read-type cycle.
And really, it's not that difficult to build, when you come right down to it. In the next couple of weeks, we'll build a simple feedreader application that works right in the browser and demonstrates all of these concepts.