tag:help-archives.hannonhill.com,2010-02-09:/discussions/xslt-formats/62-problem-parsing-rss-feedCascade CMS: Discussion 2012-01-26T21:00:23Ztag:help-archives.hannonhill.com,2010-02-09:Comment/71418062011-05-13T19:07:15Z2011-05-13T19:07:15ZProblem parsing RSS feed<div><p>If you take a look at the source code of the feed you'll notice
that it has a few different namespaces associated with it:</p>
<pre>
<code><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us" xmlns:media="http://search.yahoo.com/mrss/"></code>
</pre>
<p>This makes things a little tricky when you are writing your XSL
and XPath statements. For one, you'll need to add the default
namespace to your stylesheet. Then, you'll need to specify the
namespace prefix to the elements you are trying to match on.</p>
<p>I modified your XSL stylesheet a bit to demonstrate. Try
something like this:</p>
<pre>
<code><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:atom="http://www.w3.org/2005/Atom">
<xsl:template match="/">
<p>
<br/>
<xsl:value-of select="count(//atom:feed)"/>
</p>
<p>
<xsl:value-of select="count(//atom:entry)"/>
</p>
</xsl:template>
</xsl:stylesheet></code>
</pre>
<p>Let me know if this helps.</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/71418062011-05-17T14:56:51Z2011-05-17T15:03:27ZProblem parsing RSS feed<div><p>That worked.<br>
Now I want to access an element attribute from the same feed:<br>
<code><link href="http://www.youtube.com/watch?v=o1RFgAZNwZk"
rel="via"/></code></p>
<p>I added a value-of instruction to your stylesheet:<br>
<code>select="atom:link@href"</code> (it should read "link" instead
of the asterisks)</p>
<p>But I get an error message: Invalid XSLT: Extra illegal tokens:
'@', 'href'<br>
What's wrong with my syntax?</p></div>espanaetag:help-archives.hannonhill.com,2010-02-09:Comment/71418062011-05-17T15:34:50Z2011-05-17T15:34:50ZProblem parsing RSS feed<div><p>Attached is the full XSLT stylesheet that returns the illegal
token error when submitted.</p></div>espanaetag:help-archives.hannonhill.com,2010-02-09:Comment/71418062011-05-17T16:46:09Z2011-05-17T16:46:09ZProblem parsing RSS feed<div><p>What is your expected output? Once I know I can point you in the
right direction.</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/71418062011-05-17T17:19:10Z2011-05-17T17:20:11ZProblem parsing RSS feed<div><p>My expected output is the value of the href attribute:</p>
<p><a href=
"http://www.youtube.com/watch?v=o1RFgAZNwZk">http://www.youtube.com/watch?v=o1RFgAZNwZk</a></p>
<p>Thanks.</p></div>espanaetag:help-archives.hannonhill.com,2010-02-09:Comment/71418062011-05-17T18:18:51Z2011-05-17T18:18:51ZProblem parsing RSS feed<div><p>Ok, since it looks like multiple <code><link></code>
elements in your feed contain that same <strong>href</strong>
attribute, I'll give you a sample where it is selecting the
<strong>href</strong> value from the <code><link></code>
element which also has the attribute/value
<strong>rel="via"</strong>:</p>
<pre>
<code><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
<xsl:template match="/">
<p>
<br/>
There are <xsl:value-of select="count(atom:feed/atom:entry)"/> videos.
</p>
<p>
Link: <xsl:value-of select="//atom:entry[position() = 1]/atom:link[@rel='via']/@href"/> videos.
</p>
</xsl:template>
</xsl:stylesheet></code>
</pre>
<p>Let me know if that helps to give you an idea of how you can
accomplish this.</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/71418062011-05-18T19:09:13Z2011-05-18T19:09:13ZProblem parsing RSS feed<div><p>That did the trick. Thanks.</p></div>espanaetag:help-archives.hannonhill.com,2010-02-09:Comment/71418062011-05-18T19:50:15Z2011-05-18T19:50:15ZProblem parsing RSS feed<div><p>No problem! Glad I could help out.</p></div>Tim