Parsing the Response
The real work begins when you're ready to parse the response from the request object. This is where you actually start working with the data that you requested. For testing purposes during development, the responseText and responseXML properties can be used to display the raw data from the response. To begin accessing nodes in the XML response, start with the request object that you created, target the responseXML property to retrieve (you guessed it) the XML from the response. Target the documentElement, which retrieves a reference to the root node of the XML response.
var response = request.responseXML.documentElement;
Now that you have a reference to the root node of the response, you can use getElementsByTagName() to retrieve childNodes by their node names. The following line locates a childNode with a nodeName of header:
Using firstChild.data allows you to access the text within the element:
Here's a complete example of how to write the code:
var response = request.responseXML.documentElement; var header = response.getElementsByTagName('header').firstChild.data; document.getElementById('copy').innerHTML = header;