1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    London
    Posts
    326
    Vote Rating
    10
    Answers
    10
    digeridoopoo will become famous soon enough

      0  

    Default Unanswered: Parsing XML Responses with convert function? Pinterest and Facebook

    Unanswered: Parsing XML Responses with convert function? Pinterest and Facebook


    Hi,

    I've had some success grabbing XML feed from Pinterest and Facebook, using the following URLS:

    http://pinterest.com/travelchanneleu/feed.rss

    https://www.facebook.com/feeds/page.php?id=51539791474&format=rss20

    I can map the feed to a model, store and view relatively easily. The problem I have is that both responses from the above links contain, for example, images and text inside one part of the response.

    My question is, how would I go about splitting up the description part below, in the pinterest description feed I get both the image and text:

    Code:
    <description>&lt;p>&lt;a href="/pin/98868154291824290/">&lt;img src="http://media-cache-ec2.pinterest.com/192x/03/45/5f/03455ff1a62e80f4c0f59c475bf416e6.jpg">&lt;/a>&lt;/p>&lt;p>Airport 24/7 : Miami   If you think you know life in an airport, think again. This is Miami Airport as you've never seen it before.&lt;/p>
    </description>
    I'm pretty sure I would have to use a convert function on the model. Would I have to do something like Ed Spender did here for his APOD carousel?

    Code:
     convert: function(value, record) {
                        var content = record.get('content'),
                            regex   = /img src=\"([a-zA-Z0-9\_\.\/\:]*)\"/,
                            match   = content.match(regex),
                            src     = match[1];
     
                        if (src != "" && !src.match(/\.gif$/)) {
                            src = "http://src.sencha.io/screen.width/" + src;
                        }
                        
                        return src;
                    }
    Any help would be much appreciated.....or any useful resources how to use the convert function on a model! I don't really understand the code above very well.

    Thanks,

    :-)

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,624
    Vote Rating
    434
    Answers
    3105
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Yes, looks like you want to change the value of that field to prefix the io url. You could do it in the convert like you are or in a view.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.