xml parsing - How to parse XML response with Sencha Touch? -


ext.ajax.request({   url: 'http://bar.com/api/foos/',   success: function(response, opts) {     // how parse response containing xml?   } }); 

i tried fiddling around xmlreader didn't far.

i'm new sencha touch i've got xml read , display ok, problem had can't access cross domain xml's (although i've heard if compile in phonegap there way), put files in same location , parsed xml php script on server (in turn keeping local). see example below:

<!doctype html> <html>     <head><meta http-equiv="content-type" content="text/html; charset=utf-8">         <title>xml example</title>         <script src="../sencha-touch-debug.js" type="text/javascript">         </script>         <link href="../resources/css/sencha-touch.css" rel="stylesheet" type="text/css">         <script type="text/javascript">             new ext.application({                 name: 'xmlexample',                 launch: function(){                     ext.regmodel('profile', {                         fields: ['nobea','nobeb','nodec','noded'] //etc...                     });                      this.stores.profiles = new ext.data.store({                         model: 'profile',                         autoload:true,                         implicitincludes: true,                         proxy: {                             type: 'ajax',                             url : 'http://www.yourwebsite.co/php/xmlparse.php?url=http://externalxmllink',                             reader: {                                 type  : 'xml',                                 root  : 'profile',                                 record: 'profile'                             }                         }                     });                 var producttpl = new ext.xtemplate(                     '<tpl for=".">',                         '<div class="data">{nobea}</div>',                         '<div class="data">{nobeb}</div>',                 '<div class="data">{nobec}</div>',                         '<div class="data">{nobed}</div>',                     '</tpl>'                 );                     new ext.panel({                     fullscreen: true,                     items: new ext.dataview({                         store: this.stores.profiles,                         tpl: producttpl,                         itemselector: 'product-selected'                         //other config goes here                     })                 });             }         });                 </script>     </head>     <body>     </body> </html> 

so sample xml file like:

<?xml version="1.0" encoding="utf-8"?> <profile> <nodea>text</nodea> <nodeb>text</nodeb> <nodec>text</nodec> <noded>text</noded> </profile> 

and here xmlparse.php

<?php // set return content type header('content-type: application/xml');  // website url open //$daurl = 'http://yourxmllink'; $daurl = $_get['url'];  // website's content $handle = fopen($daurl, "r");  // if there something, read , return if ($handle) {     while (!feof($handle)) {         $buffer = fgets($handle, 4096);         echo $buffer;     }     fclose($handle); } ?> 

hope helps :)


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -