Search

I've got a few videos that I need to grab just the youtube src attribute from an oembed XML output.

I thought I could grab this attribute with exslt:

<xsl:variable name="code"><xsl:value-of select="//data/work-entry/entry/video/oembed/html" disable-output-escaping='yes'/></xsl:variable>
                <div style="display:none">
                  <xsl:variable name="iframe" select="exsl:node-set($code)"/>
                  <xsl:value-of select="$iframe//@src"/>
                </div>

But I just get an empty result..

I'm just after a string such as this: http://www.youtube.com/embed/VRNuKfBhehk?feature=oembed from an oembed script that has escaped iframe opening and closing tags..

Any toughts?

Hey Moonoo,

This should work, with normal xslt;

<xsl:variable name="stringafter"><xsl:value-of select="substring-after(video/oembed/html,'src=&quot;')" /></xsl:variable>
<xsl:variable name="code"><xsl:value-of select="substring-before($stringafter,'&quot;')" /></xsl:variable>
<div style="display:none">
    <xsl:value-of select="$code"/>
</div>

But why don't u just use the url node?

Cheers

I want to define width and height and Id's on the iframe that don't exist in the oembed code.. and youtube oembed doesn't provide the unique ID of the video as a spearate node..

I just string replaces the 'url' node in oembed to grab the ID and now it's sorted... he says :)

Thanks for the above though!

Yep, that was the same thing i did, rebuilding the iframe to set your own attributes...
I wonder if there's a better 'ninja technique' to grab attributes from a string?

I think the Ninja approach was what I was attempting.. but I only managed 'Kato' level of Ninja :p

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