Note that there are some explanatory texts on larger screens.

plurals
  1. POParse an XML into a database with phonegap/Jquery/Ajax
    primarykey
    data
    text
    <p>Hey everyone I was would greatly appreciate some help here, I am trying to parse an XML and put the results into a database for an app I am working on(Phonegap/JQuery mobile app). Can someone show me how to do this inside of a JS function? </p> <p>I understand the parsing process for the XML however I am a little lost on storing it locally into the SQLlite database that phonegap lets you access. Here is the XML I am using:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;orders&gt; &lt;order&gt; &lt;orderId&gt;123456789&lt;/orderId&gt; &lt;city&gt;Cincinnati&lt;/city&gt; &lt;state&gt;Ohio&lt;/state&gt; &lt;zip&gt;45451&lt;/zip&gt; &lt;/order&gt; &lt;/orders&gt; </code></pre> <p>Here is a JS function to parse this: </p> <pre><code> $(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('&lt;div&gt;'); $("#acceptedOrdersContent").append('&lt;h3&gt;'OrderId: '+ orderId + '&lt;/h3&gt;'); $("#acceptedOrdersContent").append('&lt;p&gt;'); $("#acceptedOrdersContent").append('City: '+ city + '&lt;br /&gt;'); $("#acceptedOrdersContent").append('State: '+ state + '&lt;br /&gt;'); $("#acceptedOrdersContent").append('Zip: '+ zip +'&lt;br /&gt;'); $("#acceptedOrdersContent").append('&lt;/p&gt;'); $("#acceptedOrdersContent").append('&lt;/div&gt;'); }); } }); }); </code></pre> <p>Thanks everyone! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload