Results 1 to 2 of 2

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

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    London
    Posts
    454
    Answers
    19
    Vote Rating
    22
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,335
    Answers
    3884
    Vote Rating
    1297
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •