1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    8
    Vote Rating
    0
    haktm is on a distinguished road

      0  

    Red face Unanswered: Reading XML Error: Unexpected token <

    Unanswered: Reading XML Error: Unexpected token <


    Hi. I have trouble with reading xml.
    Here is my code:
    PHP Code:
    Ext.onReady(function() {
        
    Ext.regModel('User', {
            
    fields: ['id']
        });

        var 
    store = new Ext.data.Store({
            
    model ' User',
            
    proxy :  new Ext.data.ScriptTagProxy({
                
    url    :  'http://some-address-link/api/getPublished.xml',
                
    reader : new Ext.data.XmlReader({
                    
    root    'qoutes',
                    
    record  'qoute'
                
    })
            })
         });
        
    store.load();
    }); 
    Chrome console's output:
    Code:
    Resource interpreted as Other but transferred with MIME type undefined.
    Uncaught SyntaxError: Unexpected token <  getPublished.xml:1
    
    My response is:
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <quotes>
        <quote>
            <id>123</id>
            <status>2</status>
            <type>quote</type>
            <add_date>1323195036</add_date>
            <pub_date>1323446160</pub_date>
            <author>User1</author>
            <author_id>123</author_id>
            <text>Some text here</text>
            <rating>30</rating>
            <tags>
                <tag id="16">tagName1</tag>
            </tags>
        </quote>
        <quote>
            <id>198</id>
            <status>2</status>
            <type>quote</type>
            <add_date>1323195036</add_date>
            <pub_date>1323446160</pub_date>
            <author>User2</author>
            <author_id>14</author_id>
            <text>Some text here</text>
            <rating>12</rating>
            <tags>
                <tag id="17">tagName2</tag>
            </tags>
        </quote>
     </quotes>
    Please help me with this issue.

  2. #2
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    222
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    This will work if you test this where you can send cross domains requests and assuming your given URL is right. I suggest testing under iOS simulator or the device. http://senchafiddle.com/#jANfO

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    8
    Vote Rating
    0
    haktm is on a distinguished road

      0  

    Default


    Nothing has changed.

    Code:
    Resource interpreted as Other but transferred with MIME type undefined.
    Uncaught SyntaxError: Unexpected token < getPublished.xml:1

  4. #4
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    222
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    Can you show me your exact url because I want confirm if it's really returning xml.

  5. #5
    Sencha User
    Join Date
    May 2011
    Posts
    8
    Vote Rating
    0
    haktm is on a distinguished road

      0  

    Default


    Do you think I would have created a post here not sure that link really return a valid xml?


    By the way, when i made java-application on android i succesfuly read this xml.
    But with sencha touch i can easily make any design what i want. And for me it's more easily because i used Extjs before.

    P.S. xml is valid.

  6. #6
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    222
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    I see. I tested similar code on the fiddle as it supports cross domain calls now and I am also getting some error. You can also see the error in firebug http://senchafiddle.com/#IBdE4

    I see there is something I am overlooking because last time I did an app everything was working perfectly fine with the same piece of code but today it's not working. I hope someone may respond here with solution. I have also just posted an issue here.

  7. #7
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    222
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    Also 2 things from your code is wrong for sure. You don't need to load the store right after creating store but set store property...

    Code:
    autoLoad: true;
    Also define type of data being returned from the server as...

    Code:
    reader : new Ext.data.XmlReader({
       type: 'xml',                
       root    : 'qoutes',
       record  : 'qoute'
    })

  8. #8
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    222
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    See I managed to get it working with JSON http://senchafiddle.com/#Pdxh5

    It was twitter's API returning invalid XML but it returns JSON fine.

  9. #9
    Sencha User
    Join Date
    May 2011
    Posts
    8
    Vote Rating
    0
    haktm is on a distinguished road

      0  

    Default



    If there are something wrong in that code, it isn't in the "autoload" and "type" of reader properties.
    autoload: true -> get the same result than function
    load()

    And in class XmlReader already set in property "type" the value "xml".

  10. #10
    Sencha User
    Join Date
    May 2011
    Posts
    8
    Vote Rating
    0
    haktm is on a distinguished road

      0  

    Default


    Twitter can't return invalid xml. It's ridiculous. If we can't read this xml, it doesn't mean what twitter is wrong, it mean that we do something wrong.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar