Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Inx51 54 posts 107 karma points
    Mar 15, 2011 @ 11:08
    Inx51
    0

    get values from youtubefeed?

    Hi!

    Im trying to do the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
        version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library"
        xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
        xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
        xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
        xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
        xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
        xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets">

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <!-- start writing XSLT -->
      <xsl:variable name="utubexml" select="umbraco.library:GetXmlDocumentByUrl('http://gdata.youtube.com/feeds/api/channels?q=dog;v=2')"/>

    <xsl:for-each select="$utubexml/*[local-name()='feed']/*[local-name()='entry']">

            <xsl:value-of select="*[local-name()='id']" disable-output-escaping="yes" />

            <hr/>

        </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

     But for some reason it doesnt work...does anyone know what I'm doing wrong?

     

    Thanks in advance!

  • Inx51 54 posts 107 karma points
    Mar 15, 2011 @ 11:10
    Inx51
    0

    and if I get this right.. xslt cant use the following url:

    gdata.youtube.com/feeds/api/channels?q=dog&v=2

    since the & is causeing some problems..so is the thing that Im doing above even correct?

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Mar 15, 2011 @ 17:38
    Tim
    1

    Have you tried URL encoding the the ampersand, e.g:

    gdata.youtube.com/feeds/api/channels?q=dog&amp;v=2

    See if that does the trick!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 15, 2011 @ 22:39
    Jan Skovgaard
    0

    If you still don't get any content when you have tried the suggestion of Tim could you please try to make a textarea in, which you write the content of your variable?

    Like this:

    <textarea>
    <xsl:copy-of select="$utubexml" />
    </textarea>

    This should give you the XML structure, which should make it fairly easy to figure out how to match it.

    /Jan

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Mar 15, 2011 @ 23:16
    Lee Kelleher
    1

    Hi Inx51,

    It's the age-old gotcha of XML namespaces... you need to reference them explictally in your XSLT.

    See here for an example: http://our.umbraco.org/forum/developers/xslt/8016-getXMLDocument-won't-display-any-content

    I'll post an example XSLT if I have time.

    Cheers, Lee.

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Mar 15, 2011 @ 23:25
    Lee Kelleher
    0

    ... so, instead of going crazy with all those "local-name()" functions, lets look at doing it a better way.

    Since the <feed> has an Atom namespace (xmlns), you'll need to reference that in your XSLT:

    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:atom="http://www.w3.org/2005/Atom"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="msxml umbraco.library">

    When you then grab the XML (by URL), you can use the "atom" namespace instead of the "local-name()" functions:

    <xsl:variable name="utubexml" select="umbraco.library:GetXmlDocumentByUrl('http://gdata.youtube.com/feeds/api/channels?q=dog&amp;v=2')"/>
    <xsl:for-each select="$utubexml/atom:feed/atom:entry">
        <xsl:value-of select="atom:title" disable-output-escaping="yes" />
        <hr/>
    </xsl:for-each>

    Namespaces can be confusing, trust me - I spend many hours/days bashing my head against a wall with this stuff!

    Cheers, Lee.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

    Continue discussion

Please Sign in or register to post replies