<p>I'm unable to view the feed via the link you've provided - seems like it may not allow public access. In any case, see a working example below using an example public RSS feed.</p>

<pre><code>{% set params = {
    url: 'http://www.feedforall.com/sample.xml',
    type: 'xml',
    element: 'item',
} %}

{% set feed = craft.feedme.feed(params) %}

{% for node in feed %}
  {{ node.category.attributes.domain }}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-10-21T14:15:27.937Z
Hmm, I see that the feedforall xml file is displayed in Chrome as an xml file. With expandable nodes. However in my own rss feed it's not rendered that way. Maybe that might be the issue. I updated my original post with a screenshot of my feed as opened in Chrome.
Kenny Bones
CC BY-SA 3.0
2015-10-21T14:27:57.710Z
Yeah, I saw the same too - now that makes sense. Thats just likely the way its outputted. It _may_ have something to do with it - it also could be that there is no inner-value for the `enclosure` node, so it ignores it. I'll have a test.
crawf
CC BY-SA 3.0
2015-10-21T15:17:59.400Z
You were right, it was that some of the enclosure nodes was empty. I added a filter `{{ node.enclosure.attributes.url|default('empty') }}`. And it's working now :)
Kenny Bones
CC BY-SA 3.0
2015-10-21T15:21:21.103Z
Awesome - I'll try to work this into the plugin - normally it would skip over nodes without an inner value, but it'll also need a check in there for attributes. Thanks!
crawf
CC BY-SA 3.0
2015-10-21T14:04:05.400Z
2015-10-21T14:04:05.400Z
crawf
<p>So I'm using FeedMe to get RSS atom feeds and this is working O.K. But there's this field that has an attribute I want to extract. And I cannot get this to work. </p>

<p>In the FeedMe documentation it says:</p>

<pre><code>For example, the XML &lt;field my_attribute="Some Value"&gt;Another Value&lt;/field&gt;, 
you can use {{ xml.field.attributes.my_attribute }}.
</code></pre>

<p>My field is called <code>'enclosure'</code> and has an attribute called <code>'url'</code> that I want to extract. According to the documentation, one would assume that this should work:</p>

<pre><code>{% set feed = craft.feedme.feed(myfeed_rss) %}

{% for node in feed %}

    {
        'title': {{ node.title | raw }},
        'description': {{ node.description | raw }},
        'url': {{ node.link | raw }},
        'date': {{ node.pubdate | raw }},
        'image': {{ node.enclosure.attributes.url | raw }}
    }

{% endfor %}
</code></pre>

<p>Namely <code>{{ node.enclosure.attributes.url }}</code> should work? All the other fields are collected correctly. So it's just this one. </p>

<p>Edit: Btw, the feed I'm using is this one. 
<a href="http://www.adressa.no/?widgetName=polarisFeeds&amp;widgetId=3185248&amp;getXmlFeed=true" rel="nofollow noreferrer">http://www.adressa.no/?widgetName=polarisFeeds&amp;widgetId=3185248&amp;getXmlFeed=true</a></p>

<p>Edit2: Managed to get it to work, with help from <a href="https://craftcms.stackexchange.com/users/632/crawf">crafw</a>. Some of the nodes weren't empty, fixed it by changing the line to:</p>

<pre><code>{{ node.enclosure.attributes.url|default('empty') }}
</code></pre>

<p><a href="https://craftcms.stackexchange.com/users/632/crawf">https://craftcms.stackexchange.com/users/632/crawf</a></p>

<p><a href="https://i.sstatic.net/jBU9v.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jBU9v.jpg" alt="RSS feed"></a></p>

<templating><rss><plugin-feedme>
FeedMe - Extracting attribute from an RSS feed field
# FeedMe - Extracting attribute from an RSS feed field

(Asked by: username_0 on 2015-10-21)

So I'm using FeedMe to get RSS atom feeds and this is working O.K. But there's this field that has an attribute I want to extract. And I cannot get this to work. 
In the FeedMe documentation it says:
For example, the XML Another Value, 
you can use {{ xml.field.attributes.my_attribute }}.

My field is called 'enclosure' and has an attribute called 'url' that I want to extract. According to the documentation, one would assume that this should work:
{% set feed = craft.feedme.feed(myfeed_rss) %}

{% for node in feed %}

    {
        'title': {{ node.title | raw }},
        'description': {{ node.description | raw }},
        'url': {{ node.link | raw }},
        'date': {{ node.pubdate | raw }},
        'image': {{ node.enclosure.attributes.url | raw }}
    }

{% endfor %}

Namely {{ node.enclosure.attributes.url }} should work? All the other fields are collected correctly. So it's just this one. 
Edit: Btw, the feed I'm using is this one. 
http://www.adressa.no/?widgetName=polarisFeeds&widgetId=3185248&getXmlFeed=true
Edit2: Managed to get it to work, with help from crafw. Some of the nodes weren't empty, fixed it by changing the line to:
{{ node.enclosure.attributes.url|default('empty') }}

https://craftcms.stackexchange.com/users/632/username_1

**Tags:** templating, rss, plugin-feedme


---

## 1 answers

### Answer by username_1 on 2015-10-21. Score: 3 | Accepted answer

I'm unable to view the feed via the link you've provided - seems like it may not allow public access. In any case, see a working example below using an example public RSS feed.
{% set params = {
    url: 'http://www.feedforall.com/sample.xml',
    type: 'xml',
    element: 'item',
} %}

{% set feed = craft.feedme.feed(params) %}

{% for node in feed %}
  {{ node.category.attributes.domain }}
{% endfor %}

> **Comments:**
> **username_0**: Hmm, I see that the feedforall xml file is displayed in Chrome as an xml file. With expandable nodes. However in my own rss feed it's not rendered that way. Maybe that might be the issue. I updated my original post with a screenshot of my feed as opened in Chrome.  
> **username_1**: Yeah, I saw the same too - now that makes sense. Thats just likely the way its outputted. It _may_ have something to do with it - it also could be that there is no inner-value for the `enclosure` node, so it ignores it. I'll have a test.  
> **username_0**: You were right, it was that some of the enclosure nodes was empty. I added a filter `{{ node.enclosure.attributes.url|default('empty') }}`. And it's working now :)  
> **username_1**: Awesome - I'll try to work this into the plugin - normally it would skip over nodes without an inner value, but it'll also need a check in there for attributes. Thanks!  

---

