I am trying to fetch an XML feed from the same domain but the obj is returning null. Below is my code.
Service
angular.module('ngAuidApp')
.service('profileInfoService', function($http){
return $http.get('scripts/user-feed.xml');
});
Controller
angular.module('ngAuidApp')
.controller('ProfileCtrl', ['$scope', 'x2js', 'profileInfoService', function ($scope, x2js, profileInfoService) {
var xmlObj = '<feed><title type="text">User Ashish Panchal - Stack Overflow</title><link rel="self" href="http://stackoverflow.com/feeds/user/3635285" type="application/atom+xml" /><link rel="alternate" href="http://stackoverflow.com/users/3635285" type="text/html" /></feed>';
var jsonOb = x2js.xml_str2json(xmlObj);
// Prints title from above xml string
console.log(jsonOb.feed.title);
// Trying to fetch from external file
profileInfoService.success(function(data){
// Print outs xml feed
console.log(data);
var jsonObj = x2js.xml_str2json(data);
// Prints null
console.log(jsonObj);
});
}]);
When I am trying to fetch feed from external file it gives null. Can someone please let me know what is missing?