JavaScript snippet to read and output XML file on page load?

Posted by Banderdash on Stack Overflow See other posts from Stack Overflow or by Banderdash
Published on 2010-05-02T17:54:26Z Indexed on 2010/05/02 18:38 UTC
Read the original article Hit count: 314

Filed under:
|

Hey guys, hoping I might get some help. Have XML file here of a list of books each with unique id and numeral value for whether they are checked out or not. I need a JavaScript snippet that requests the XML file after the page loads and displays the content of the XML file.

XML file looks like this:

    <?xml version="1.0" encoding="UTF-8" ?>
    <response>
      <library name="My Library">
        <book id="1" checked-out="1">
          <authors>
            <author>John Resig</author>
          </authors>
          <title>Pro JavaScript Techniques (Pro)</title>
          <isbn-10>1590597273</isbn-10>
        </book>
        <book id="2" checked-out="0">
          <authors>
            <author>Erich Gamma</author>
            <author>Richard Helm</author>
            <author>Ralph Johnson</author>
            <author>John M. Vlissides</author>
          </authors>
          <title>Design Patterns: Elements of Reusable Object-Oriented Software</title>
          <isbn-10>0201633612</isbn-10>
        </book>
        ...
      </library>
    </response>

Would LOVE any and all help!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about Xml