Quantcast
Channel: Parse xml tag in a AngularJS feed - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Parse xml tag in a AngularJS feed

$
0
0

I need parse the enclosure tag in order to get the url image. It's assumed I should get the MIXED OUTPUT with the json+xml code but I get a undefined value from the enclousure tag when I try parse it. I'm doing this like I saw at this post >Google Feed Loader API ignoring XML attributes< .In addition I tried to get the MIXED format writing the url manually but It doesn't work. There is my whole code. How could I know that Im getting the mixed json output?

    var feeds = [];var entryImageUrl = [];angular.module('starter.controllers', ['ngResource','ngLocale']).factory('FeedLoader', function ($resource) {        return $resource('http://ajax.googleapis.com/ajax/services/feed/load', {}, {            fetch: { method: 'JSONP', params: {v: '1.0', callback: 'JSON_CALLBACK', output: 'json_xml'} }        });}).service('FeedList', function ($rootScope, FeedLoader) {    this.get = function() {        var feedSources = [            {title: 'Heraldo De Barbate', url: 'http://www.heraldodebarbate.es/rss/last'},        ];        if (feeds.length === 0) {            for (var i=0; i<feedSources.length; i++) {                FeedLoader.fetch({q: feedSources[i].url, num: 10}, {}, function (data) {                    var feed = data.responseData.feed;                    **var entryImageUrl = feed.xmlNode.getElementsByTagName("enclosure")[i].getAttribute("url");**                    feeds.push(feed);                });            }        }        return feeds;    };}).controller('FeedCtrl', function ($scope, FeedList,$timeout) {  $scope.update = function(){    $scope.feeds = FeedList.get();    $scope.$on('FeedList', function (event, data) {        $scope.feeds = data;        // $scope.entryImageUrl         console.log(feeds);    });    $timeout(function() {      $scope.$broadcast('scroll.refreshComplete');    }, 500);      }})

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images