1

I'm just finalising an iOS app made in Appcelerator at the moment and need it to pull in images from an iTunes podcast XML feed.

This is the part I need to extract.

<media:content url="http://linktomyimage.com/image.jpg" medium="image">
<media:title type="html">Media Title Example</media:title>
</media:content>

I need to get the "url" from the media:content node.

This is what I'm trying to use, but it doesn't work (podcastImage is my variable).

var doc = this.responseXML.documentElement;
            var items = doc.getElementsByTagName("item");
            var x = 0;
            var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue;
            for (var c = 0; c < items.length; c++) {
                var item = items.item(c);
                var podcasts = item.getElementsByTagName("title");
                if (podcasts && podcasts.length > 0) {
                    var media = podcasts.item(0).getAttribute("url");
                    var title = item.getElementsByTagName("title").item(0).text;
                    var description = item.getElementsByTagName("content:encoded").item(0).text;
                    var podcastURL = item.getElementsByTagName("enclosure").item(0).getAttribute("url");
                    var publishDate = item.getElementsByTagName("pubDate").item(0).text;
                    var podcastImage = item.getElementsByTagName("media:content").item(0).getAttribute("url");

Any ideas? Simon

Simon Hume
  • 982
  • 3
  • 11
  • 27
  • Do you get any error messages on your browser's console? Maybe a [CORS problem](http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource)? – janih Nov 02 '14 at 13:04

1 Answers1

0

Try this:

$node->getElementsByTagNameNS('*', 'content')->item(0)->getAttribute('url')
Tim S.
  • 385
  • 1
  • 2
  • 6