Search

Hi all,

I'm pulling in the Instagram RSS feed for recent images attached to a hashtag. There are some 'media' tags that I'm unsure how to grab.

The feed structure is:

<instagram>
<channel>
    <item>
        <title></title>
        <link></link>
        <description></description>
        <pubDate></pubDate>
        <guid></guid>
        <media:title></media:title>
        <media:description></media:description>
        <media:content url="" width="" type=" height=""/>
        <media:thumbnail url="" width="" height=""/>
        <media:credit role="photographer"></media:credit>
    </item>

I've had no problems getting most of the stuff I need out of it, however I'm interested in grabbing the data contained within <media:credit>. How do I go about it?

Also, while I'm here (as I may need this as well) how do I retrieve the data from the attributes in the tag? i.e. the 'role' within media:credit.

If there's a great resource somewhere that will answer my question more efficiently please feel free to point me there!

Cheers

Well, if you take a look at the very top of the feed you'll see media being defined as an XML-Namespace. Just define the same namespace in your stylesheet and you'll be able to access those elements in your expressions.

Hi phoque,

I think I get it now :) Saw similar treatment on the Twitter feed tutorial for the Atom feed.

Declaring: xmlns:media="http://search.yahoo.com/mrss/" in the stylesheet enabled me to grab the data via <xsl:value-of select="media:credit"/>.

I'm still new to the whole XSL/XML thing - so concepts don't always click the first time round!

Appreciate the help!

Declaring: xmlns:media="http://search.yahoo.com/mrss/" in the stylesheet enabled me to grab the data via <xsl:value-of select="media:credit"/>.

Yes, that's the idea. You could also declare xmlns:e="http://search.yahoo.com/mrss/" and then grab via <xsl:value-of select="e:credit"/>

Meaning: the shorthandle can be anything you like, the important thing is the URL.

Aaah, good to know! Cheers.

And to answer my own question (incase anyone else ends up here), to fetch the attribute values I needed to use @.

i.e. <xsl:value-of select="media:credit/@role"/>

Do either of you have a publicly-available Instagram extension or plugin or even a Github Gist of your solution that I could look at? I'd like to look at creating something for our project that could pull in posts from Instagram.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details