Javascript 在AngularJS提要中解析xml标记

Javascript 在AngularJS提要中解析xml标记,javascript,xml,json,angularjs,feed,Javascript,Xml,Json,Angularjs,Feed,我需要解析enclosure标记以获取url图像。假设我应该得到json+xml代码的混合输出,但是当我尝试解析它时,我从Enclosure标记中得到了一个未定义的值。我正在做这件事,就像我在这篇文章中看到的那样>

我需要解析enclosure标记以获取url图像。假设我应该得到json+xml代码的混合输出,但是当我尝试解析它时,我从Enclosure标记中得到了一个未定义的值。我正在做这件事,就像我在这篇文章中看到的那样><。此外,我试图用混合格式手动编写url,但它不起作用。这是我的全部密码。我怎么知道我得到了混合json输出

    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);    
  }
})
var提要=[];
变量entryImageUrl=[];
angular.module('starter.controllers',['ngResource','ngLocale'])
.factory('FeedLoader',函数($resource){
返回$resource('http://ajax.googleapis.com/ajax/services/feed/load', {}, {
fetch:{method:'JSONP',params:{v:'1.0',callback:'JSON_callback',output:'JSON_xml'}
});
})
.service('FeedList',函数($rootScope,FeedLoader){
this.get=函数(){
var馈线源=[
{标题:'Heraldo De Barbate',url:'http://www.heraldodebarbate.es/rss/last'},
];
如果(feeds.length==0){
对于(var i=0;i
我怎么知道我得到了混合json输出

    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);    
  }
})
对JSON中的标记使用测试:

function testMe(node)
  {
  return /</.test(JSON.stringify(node) )
  }
并调用另一个解析数据的函数:

if (mixed_format)
  {
  mixed_parser(feed)
  }
else
  {
  json_parser(feed)
  }