Use this:
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" /> <script src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script> <script type="text/javascript"> $(function() { $("#requestXML").click(function() { $.ajax({ type: "POST", url: "http://www.edumobile.org/blog/uploads/XML-parsing-data/Data.xml", data: "{}", cache: false, dataType: "xml", success: onSuccess }); }); $("#resultLog").ajaxError(function(event, request, settings, exception) { $("#resultLog").html("Error Calling: " + settings.url + "<br />HTTP Code: " + request.status); }); function onSuccess(data) { $("#resultLog").append(""+data); $(data).find("Book").each(function () { $("#resultLog").append("<br> Name: " + $(this).attr("name")); $("#resultLog").append("<br> Address: " + $(this).attr("address")); $("#resultLog").append("<br> Country: " + $(this).attr("country")); $("#resultLog").append("<br><hr>"); }); } }); </script>
Call button of the above method:
<input id="requestXML" type="button" value="Request XML" />
source share