Hello everyone, I could really use some assistance here. I am currently working on an app using Phonegap/JQuery mobile and I need help parsing XML data and storing it in a SQLite database. Can someone guide me on how to achieve this within a JavaScript function?
I have a good understanding of how to parse the XML data, but I am struggling with the process of saving it locally into the SQLite database that is accessible through Phonegap. Below is the XML data I am working with:
<?xml version="1.0" encoding="UTF-8"?>
<orders>
<order>
<orderId>123456789</orderId>
<city>Cincinnati</city>
<state>Ohio</state>
<zip>45451</zip>
</order>
</orders>
Here is a sample JavaScript function for parsing this XML data:
$(document).ready(function(){
$.ajax({
type: "GET",
url: "testOrders.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('order').each(function(){
orderId = $(this).find("orderId").text();
city = $(this).find("city").text();
state = $(this).find("state").text();
zip = $(this).find("zip").text();
$("#acceptedOrdersContent").append('<div>');
$("#acceptedOrdersContent").append('<h3>'OrderId: '+ orderId + '</h3>');
$("#acceptedOrdersContent").append('<p>');
$("#acceptedOrdersContent").append('City: '+ city + '<br />');
$("#acceptedOrdersContent").append('State: '+ state + '<br />');
$("#acceptedOrdersContent").append('Zip: '+ zip +'<br />');
$("#acceptedOrdersContent").append('</p>');
$("#acceptedOrdersContent").append('</div>');
});
}
});
});
Thank you in advance for your help!