1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    29
    Vote Rating
    0
    mr.xprt is on a distinguished road

      0  

    Default how to read XML item's attribute ?!

    how to read XML item's attribute ?!


    hi,

    am trying to build simple Rss Reader but i have some troubles

    item trying to read :
    Code:
    <item>
     <title>Example</title>
     <link>http://www.example.com</link>
     <description>test .. test</description>
     <enclosure url="http://www.example.com/1301129331005742800.jpg" />
     <dc:creator>test</dc:creator>
    </item>
    <enclosure url="http://www.example.com/1301129331005742800.jpg" />

    my regModel:
    Code:
    Ext.regModel('rss', {
        fields: ['title','description','link','creator', 'enclosure']
    });
    so "enclosure" come with empty string

    after search i tried :

    Code:
    Ext.regModel('rss', {
        fields: ['title','description','link','creator',{name: 'enclosure',mapping:'@url'}]
    });
    but i got that error :
    Code:
    Uncaught Error: SYNTAX_ERR: DOM Exception 12

    how can i get the url ?!
    Still Learning .... Still Expert

  2. #2
    Sencha User
    Join Date
    Feb 2011
    Posts
    29
    Vote Rating
    0
    mr.xprt is on a distinguished road

      0  

    Default


    any ideas ?!
    Still Learning .... Still Expert

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    1
    Vote Rating
    0
    tjozsa is on a distinguished road

      0  

    Default same issue here

    same issue here


    Hi,

    Having the same issue now with latest sencha touch lib.

    Have you been able to find a workaround. Or is someone there who has a solution???

    Regards,
    Tamas

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    24
    Vote Rating
    0
    erhandemirci is on a distinguished road

      0  

    Wink how parse attribute?

    how parse attribute?


    Ext.regModel('User', {
    fields: [
    {name: 'id', type: 'int'},
    {name: 'firstName', type: 'string'},
    {name: 'lastName', type: 'string'},
    {name: 'partname', mapping: 'partname',type:'string'}
    ]
    });


    <Contact>
    <id>1</id>
    <firstName>Julio</firstName>
    <lastName>Benesh</lastName>
    <part partname="partion0"></part>
    </Contact>
    <Contact>

    ????????????????????????????????????????????

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Posts
    2
    Vote Rating
    0
    bbjay is on a distinguished road

      0  

    Default I had the same issue

    I had the same issue


    my solution:
    Code:
    store: {
                    storeId: 'News-online',
                    fields: ['title','pubDate', 'description',{
                        name: 'img_url',
                        convert: function(value, record){
                                var enc = record.raw.getElementsByTagName('enclosure')[0];
                                return enc.attributes.getNamedItem('url').value;
                                               }
                    } ],
                    autoLoad: true,
                    proxy: {
                        type: 'ajax',
                        url: 'feed.xml',
                        reader: {
                            type: 'xml',
                            root: 'channel',
                            record:'item'
                        }
                    }
                },

Similar Threads

  1. How does an Ext.store read a object item inner jsondata?
    By sunphy in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 12 Jul 2008, 1:54 AM
  2. How to read attribute'data From a XML file?
    By aswangod in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 9 Mar 2008, 9:28 PM
  3. How to read attribute with xmlReader?
    By dolittle in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 28 Sep 2007, 10:07 AM
  4. How to read attribute values of XML tag using XmlReader
    By tookoo in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 30 May 2007, 10:09 AM

Thread Participants: 3