jQueryでXMLを解析して表示させるサンプルコードが紹介されていたのでメモ![ひらめき電球](https://stat.ameba.jp/blog/ucs/img/char/char2/089.gif)
簡単にXMLを扱えるんですね。
jQueryでXMLをパースして表示するコードサンプル例
Parse XML with jQuery
jQueryでXMLをパースして表示する方法
途中で改行しているのでコピペだと上手く動作しない可能性があります。
![ひらめき電球](https://stat.ameba.jp/blog/ucs/img/char/char2/089.gif)
簡単にXMLを扱えるんですね。
jQueryでXMLをパースして表示するコードサンプル例
Parse XML with jQuery
jQueryでXMLをパースして表示する方法
$(document).ready(function () {
$.ajax({
type: "GET",
url: "books.xml",
dataType: "xml",
success: xmlParser
});
});
function xmlParser(xml) {
$('#load').fadeOut();
$(xml).find("Book").each(function () {
$(".main").append('<div class="book"><div class="title">' +
$(this).find("Title").text() +
'</div><div class="description">' +
$(this).find("Description").text() +
'</div><div class="date">Published ' +
$(this).find("Date").text() + '</div></div>');
$(".book").fadeIn(1000);
});
}
途中で改行しているのでコピペだと上手く動作しない可能性があります。