Last active
December 17, 2015 12:39
-
-
Save z3bbster/5611443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Load XML file | |
$(document).ready(function(){ | |
$("#dvContent").append("<ul></ul>"); | |
$.ajax({ | |
type: "GET", | |
url: "BookList.xml", | |
dataType: "xml", | |
success: function(xml){ | |
$(xml).find('Book').each(function(){ | |
var sTitle = $(this).find('Title').text(); | |
var sPublisher = $(this).find('Publisher').text(); | |
$("<li></li>").html(sTitle + ", " + sPublisher).appendTo("#dvContent ul"); | |
}); | |
}, | |
error: function() { | |
alert("An error occurred while processing XML file."); | |
} | |
}); | |
}); | |
//Code Ends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<BookList> | |
<Book> | |
<Title>jQuery: Novice to Ninja</Title> | |
<Publisher>Site point</Publisher> | |
</Book> | |
<Book> | |
<Title>Learning jQuery</Title> | |
<Publisher>PACKT</Publisher> | |
</Book> | |
<Book> | |
<Title>Head First jQuery</Title> | |
<Publisher>O'Reilly</Publisher> | |
</Book> | |
<Book> | |
<Title>jQuery UI 1.8</Title> | |
<Publisher>PACKT</Publisher> | |
</Book> | |
</BookList> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment