how to parse a xml file using jquery and phonegap?

508 views Asked by At
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
    $("#dvContent").append("<div></div>");
    $.ajax({
        type: "GET",
        url: "products.xml",
        dataType: "xml",
        success: function(xml){
            $(xml).find('product').each(function(){
            var sModel = $(this).find('model').text();
            var sName = $(this).find('name').text();
            var sDescription = $(this).find('description').text();
            var sImage = $(this).find('image').text();
            var sPrice = $(this).find('price').text();
            var sSpecial = $(this).find('specialPrice').text();
            $("<li></li>").html(sModel + ", " + sName + ", " + sDescription + ", " + sImage + ", " + sPrice + ", " + sSpecial ).appendTo("#dvContent div");
        });
        },
        error: function() {
        alert("An error occurred while processing XML file.");
        }
    });
  });    
 </script>
</head>
<body>
<form id="form1" runat="server">
<div id="dvContent">

</div>
</form>
</body>
</html>

this is the complete code that i have written to parse a xml file and display it in a html page. I am parsing this for the sake of an mobile app. I am using phonegap for it, but the problem that i am facing is due to the use of regular jquery i am getting a lot of errors. So can one help me with what all changes that has to be done in the file to get it woking properly in phonegap?

0

There are 0 answers