you’re on your way 4
351
xml requests and responses
Using responseXML in your code
You’ve already seen that the responseText property of your request
object lets you read the XML that the server responds with. But we don’t
want a bunch of text that looks like XML; we’re DOM experts now, right?
Using the responseXML property, you can get the DOM tree for the
server’s response, and then work with that XML using the DOM.
And since the HTML for Katie’s Boards report is another DOM tree, we
just want to grab values from the XML DOM and stick them in the HTML
DOM. Let’s see exactly what we need to do:
Even if you don’t feel like an
expert, you’re kicking butt!
And by the time you nish this
chapter, you’ll be even better at
the DOM than you are now.
totals
boards-sold
boots-sold
bindings-sold
“1710“
“315“
“85“
Here’s the XML DOM from
the Boards server.
span id=”boards-sold”
span id=”bindings-sold”
span id=”boots-sold”
“1710“
“315“
“85“
Here’s Katie’s web report,
with a few of the <span>
elements in the DOM
tree called out.
We need to take the values from the XML
DOM tree and use them to update the
values in the HTML DOM tree.
The browser puts this DOM tree
in the responseXML property of
the request object.