you can use it for parsing xml for s40 :
Code:
$(document).ready(function () {
jQuery.support.cors = true;
$.ajaxSetup({
error:function(x,e){
if(x.status==0){
alert('You are offline!!\n Please Check Your Network.');
window.location = 'index.html';
}else if(x.status==404){
alert('Requested URL not found.');
window.location = 'index.html';
}else if(x.status==500){
alert('Internel Server Error.');
window.location = 'index.html';
}else if(e=='parsererror'){
alert('Error.\nParsing JSON Request failed.');
window.location = 'index.html';
}else if(e=='timeout'){
alert('Request Time out.');
window.location = 'index.html';
}else {
alert('Unknow Error.\n'+x.responseText);
window.location = 'index.html';
}
}
});
$.ajax({
type: "GET",
url: "http://data.bmkg.go.id/lastgempadirasakan.xml",
crossDomain: true,
dataType: "xml",
success: xmlParser
});
});
function xmlParser(xml) {
$('#load').fadeOut();
$(xml).find("Gempa").each(function () {
$(".main").append('<center><b>Terjadi Gempa Dirasakan ' + $(this).find("Magnitude").text() + ' </b></center><br>Tanggal : ' + $(this).find("Tanggal").text() + ' <br> Waktu : ' + $(this).find("Jam").text() + '<br>' + $(this).find("Keterangan").text() + ', dirasakan di ' + $(this).find("Dirasakan").text() + '');
$(".bmkg").fadeIn(1000);
});
}
Replace xml url : http://data.bmkg.go.id/lastgempadirasakan.xml with your xml. And note the structure of the xml.
Edit this part :
Code:
function xmlParser(xml) {
$('#load').fadeOut();
$(xml).find("Gempa").each(function () {
$(".main").append('<center><b>Terjadi Gempa Dirasakan ' + $(this).find("Magnitude").text() + ' </b></center><br>Tanggal : ' + $(this).find("Tanggal").text() + ' <br> Waktu : ' + $(this).find("Jam").text() + '<br>' + $(this).find("Keterangan").text() + ', dirasakan di ' + $(this).find("Dirasakan").text() + '');
$(".bmkg").fadeIn(1000);
});
}
CMIIW