getElementsByTagName('book'); // get all song nodes
var container = document.getElementById('books');
container.innerHTML = doc.firstChild.data;
XSLT
One reason to use XML as a data format is to take advantage of XSLT, which is a transformation
language that converts an XML document into another format (most often another XML
format such as XHTML). Unfortunately, cross-browser support is often slow or buggy with
libraries built to address these shortcomings:
??? Google AJAXSLT (http://goog-ajaxslt.sourceforge.net/): Google released its crossbrowser
XSLT library as open source and it includes support for Safari 1.3+, Opera 7.5+,
IE 6+, and Firefox 1+.
??? Sarissa (http://dev.abiss.gr/sarissa/): Sarissa acts as a cross-browser wrapper for a
number of XML application programming interfaces (APIs), including XMLDocument,
XMLElement, XMLHttpRequest, XMLSerializer, and XSLTProcessor.
CHAPTER 5 n AJAX AND DATA EXCHANGE 113
Because client-side XSLT is almost always intended to convert an XML document into
HTML, I recommend that you avoid the hassle of dealing with cross-browser issues and create
the HTML snippet on the server side.
Alternatives to XML
As handy as XML might seem to be, it??™s not without its downsides. It can be a complicated
method of navigating the document and it is verbose. Also, having to deal with a variety of
cross-browser issues is never fun. So, you can turn to responseText and discover some other
possibilities.
Pages:
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179