Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8141789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:37:45+00:00 2026-06-06T12:37:45+00:00

So, hopefully this will be my final request for help on this project, as

  • 0

So, hopefully this will be my final request for help on this project, as you guys have already helped so much already.

Basically, I’m writing some code that takes a YouTube playlist and converts it to an RSS feed. I’ve gotten it to work the way I want to, except for one minor detail: I’m not sure why, but I need to remove one of the namespaces from the YouTube XML before it will compile.

The namespace declaration from YouTube looks like this:

<feed xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:gml='http://www.opengis.net/gml' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:georss='http://www.georss.org/georss' gd:etag='W/&quot;A04NRn47eCp7I2A9WhJTF0g.&quot;'>

Normally, I’d use the exact same ones, except for whatever reason if I include the xmlns='http://www.w3.org/2005/Atom' segment, the whole thing returns null.

Up until now, my technique has been to just chop that line out of the YouTube XML, however this strikes me as a tad inelegant. If someone who knows more about this than I do could point out what’s wrong with my current code, I’d greatly appreciate it.

Adam

EDIT: For reference, here’s my XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007' gd:etag='W/&quot;Ak8EQX47eCp7I2A9WhdSEkQ.&quot;'>

<xsl:template match="/">
<xsl:for-each select="entry">
<xsl:if test="yt:position &lt; 3">
    <item>

        <title><xsl:value-of select="title" /></title>
        <xsl:variable name="videoid" select="substring-before(substring-after(media:group/media:content/@url, 'v/'), '?')" />   <!--Extracting the YouTube video ID--> 
        <description>
            <embed src="http://www.youtube.com/v/{$videoid}" type="application/x-shockwave-flash" allowscriptaccess="never" allowfullscreen="true" width="500" height="300"></embed>    <!--Embed code for the video-->
            <br />
            <br />
            <xsl:call-template name="ParseLink">    <!--Parses the video description such that URLs become links-->
                <xsl:with-param name="text" select="media:group/media:description" />   
            </xsl:call-template>
            <img src="http://i.ytimg.com/vi/{$videoid}/hqdefault.jpg" style="display:none"/>    <!--Includes hidden thumbnail-->
        </description>

        <link>http://www.youtube.com/watch?v=<xsl:value-of select="$videoid" /></link>  <!--Link to video on YouTube-->
        <guid isPermaLink="false">http://www.youtube.com/watch?v=<xsl:value-of select="$videoid" /></guid>


    </item>
</xsl:if>
</xsl:for-each>
</xsl:template>

<xsl:template name="ParseLink"> <!--YouTube automatically turns URLs into links, this performs the same function for RSS-->
    <xsl:param name="text"/>
    <xsl:choose>

        <xsl:when test="contains($text,'http')">            
            <a href="http{substring-before(substring-after($text, 'http'), '&#xA;')}">Watch the complete video on our website</a>
            <br/>
            <xsl:call-template name="ParseText">    <!--Once the link is found, parses the rest of the text-->
                <xsl:with-param name="text">
                    <xsl:value-of select="substring-after($text,'&#xA;')"/>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:when>

        <xsl:otherwise>
            <xsl:value-of select="$text"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="ParseText"> <!--Replaces line breaks in the description to <br> tags-->
    <xsl:param name="text"/>
    <xsl:choose>

        <xsl:when test="contains($text,'&#xA;')">
            <xsl:value-of select="substring-before($text,'&#xA;')"/>
            <br />
            <xsl:call-template name="ParseText">
                <xsl:with-param name="text">
                    <xsl:value-of select="substring-after($text,'&#xA;')"/>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:when>

        <xsl:otherwise>
            <xsl:value-of select="$text"/>
        </xsl:otherwise>

    </xsl:choose>
</xsl:template>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:37:47+00:00Added an answer on June 6, 2026 at 12:37 pm

    The reason your stylesheet does not work is because you don’t have the Atom namespace defined… The default namespace from YouTube is http://www.w3.org/2005/Atom. If you want to match on the “feed” node, you would have a stylesheet like this:

    <xsl:stylesheet xmlns:atom="http://www.w3.org/2005/Atom" ... more stuff ... >
        <xsl:template match="/atom:feed">
            etc. etc.
        </xsl:template>
    </xsl:stylesheet>
    

    EDIT:
    Here’s an example stylesheet that works:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"         xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:yt="http://gdata.youtube.com/schemas/2007" gd:etag="W/&quot;Ak8EQX47eCp7I2A9WhdSEkQ.&quot;">
        <xsl:template match="/atom:feed">
            <xsl:apply-templates select="atom:entry"/>
        </xsl:template>
        <xsl:template match="atom:entry">
                <p>Entry:<xsl:value-of select="atom:title"/>
                </p>
        </xsl:template>
    </xsl:stylesheet>
    

    EDIT:
    OK, Here’s your updated stylesheet:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"         xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"     xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"     xmlns:gd="http://schemas.google.com/g/2005"     xmlns:yt="http://gdata.youtube.com/schemas/2007"     gd:etag="W/&quot;Ak8EQX47eCp7I2A9WhdSEkQ.&quot;">
        <xsl:template match="/atom:feed">
            <xsl:for-each select="atom:entry">
                <item>
                    <title>
                    <xsl:value-of select="atom:title"/>
                </title>
                <xsl:variable name="videoid" select="substring-before(substring-after(media:group/media:content/@url, 'v/'), '?')"/>
                <!--Extracting the YouTube video ID-->
                <description>
                    <embed src="http://www.youtube.com/v/{$videoid}" type="application/x-shockwave-flash" allowscriptaccess="never" allowfullscreen="true" width="500" height="300"/>
                    <!--Embed code for the video-->
                    <br/>
                    <br/>
                    <xsl:call-template name="ParseLink">
                        <!--Parses the video description such that URLs become links-->
                        <xsl:with-param name="text" select="media:group/media:description"/>
                    </xsl:call-template>
                    <img src="http://i.ytimg.com/vi/{$videoid}/hqdefault.jpg" style="display:none"/>
                    <!--Includes hidden thumbnail-->
                </description>
                <link>http://www.youtube.com/watch?v=<xsl:value-of select="$videoid"/>
                </link>
                <!--Link to video on YouTube-->
                <guid isPermaLink="false">http://www.youtube.com/watch?v=<xsl:value-of select="$videoid"/>
                </guid>
            </item>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="ParseLink">
        <!--YouTube automatically turns URLs into links, this performs the same function for RSS-->
        <xsl:param name="text"/>
        <xsl:choose>
            <xsl:when test="contains($text,'http')">
                <a href="http{substring-before(substring-after($text, 'http'), '&#xA;')}">Watch the complete video on our website</a>
                <br/>
                <xsl:call-template name="ParseText">
                    <!--Once the link is found, parses the rest of the text-->
                    <xsl:with-param name="text">
                        <xsl:value-of select="substring-after($text,'&#xA;')"/>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$text"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="ParseText">
        <!--Replaces line breaks in the description to <br> tags-->
        <xsl:param name="text"/>
        <xsl:choose>
            <xsl:when test="contains($text,'&#xA;')">
                <xsl:value-of select="substring-before($text,'&#xA;')"/>
                <br/>
                <xsl:call-template name="ParseText">
                    <xsl:with-param name="text">
                        <xsl:value-of select="substring-after($text,'&#xA;')"/>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$text"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hopefully this will be an easy answer for some of you CSS veterans out
New to MVC, so hopefully this will be pretty simple. I have an HTML
Hopefully this will be an easy question! I have two tables, a 'client(s)' table
Hopefully this will be clear enough. I have a 2d map made of tiles,
I have just started looking at javascript so hopefully this will be something simple.
Hopefully this will not spark a religious war... We have a web based app
Hopefully this explanation will make sense, but what is the best way (if it
I've tried to simplify for the purposes of asking this question. Hopefully, this will
( Late edit: This question will hopefully be obsolete when Java 7 comes, because
Hopefully this is simple: I have a relatively long list where each list item

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.