YouTube APIs and Tools

The YouTube APIs and Tools let you bring the YouTube experience to your webpage, application, or device. The Data API lets you perform most of the operations a normal YouTube user can on the YouTube website. The Player APIs let you control the YouTube player using JavaScript or ActionScript. You can also use the basic embedded player, which already contains player controls, or the chromeless player, which lets you create your own player controls.

Read more here  http://code.google.com/apis/youtube/getting_started.html

A video widget fro your blog

A video widget fro your blog

<div style="text-align:center;">
<object width="480" height="385">
<param name="movie" value="http://www.youtube.com/v/d9_kjdcA9Pc&amp;hl=en_US&amp;fs=1&amp;" />
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
<embed src="http://www.youtube.com/v/d9_kjdcA9Pc&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="280" height="185">
</embed>
</object>
<div style="color:#FFFFFF;text-align:center;height:18px;margin-top:3px;">
<a href="http://www.lifewidget.com"></a>
</div>
</div>

Display CDATA with XSL

I've been playing around with it and there's something I can't figure out.

The XML is based of an RSS Feed. Here's a example of XML I am trying to play with.

<item>
   <title>Dinner at Chilis</title>
   <link></link>
   <description>
       [!CDATA[<div><b>Location:</b> Chilis </div>
                     <div><b>Start Time:</b> 4/21/2010</div>
                     <div><b>Description:</b> Dinner at Chilis </div>]]>
    </description>
</item>

Here's a part of the XSL I've been playing around.
<xsl:template match="item">
    <xsl:value-of select="title"/>
    <xsl:value-of disable-output-escaping="yes" select="substring-before(substring-after(description, ']]'), '[CDATA[') "/>
</xsl:template>

I'm not sure why it's not displaying the string.

My previous code was like this:
<xsl:template match="item">
    <xsl:value-of select="title"/>
    <xsl:value-of disable-output-escaping="yes" select="description"/>
</xsl:template>
It displays, but I won't have control on how to select the specific text in the description tag.

It's something I want to learn how to do it. I'm still a beginner in XSL so my apologies for being a newbie. Tongue out

EDIT*
Ok. I got it.
It displays only the first line though. lol. Here's the code I have right now.
<xsl:template match="item">
    <xsl:value-of select="title"/>
    <xsl:value-of disable-output-escaping="yes" select="substring-before(substring-after(description, '&lt;div&gt;'), '&lt;/div&gt;') "/>
</xsl:template>

So far so good. I'll play around a bit more.

libxml writer - XML writer

<?php 

// THIS IS ABSOLUTELY ESSENTIAL - DO NOT FORGET TO SET THIS 
@date_default_timezone_set("GMT"); 

$writer = new XMLWriter(); 
// Output directly to the user 

$writer->openURI('php://output'); 
$writer->startDocument('1.0'); 

$writer->setIndent(4); 

// declare it as an rss document 
$writer->startElement('rss'); 
$writer->writeAttribute('version', '2.0'); 
$writer->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom'); 


$writer->startElement("channel"); 
//---------------------------------------------------- 
//$writer->writeElement('ttl', '0'); 
$writer->writeElement('title', 'Latest Products'); 
$writer->writeElement('description', 'This is the latest products from our website.'); 
$writer->writeElement('link', 'http://www.domain.com/link.htm'); 
$writer->writeElement('pubDate', date("D, d M Y H:i:s e")); 
    
$writer->startElement('image'); 
        
$writer->writeElement('title', 'Latest Products'); 
        
$writer->writeElement('link', 'http://www.domain.com/link.htm'); 
        
$writer->writeElement('url', 'http://www.iab.net/media/image/120x60.gif'); 
        
$writer->writeElement('width', '120'); 
        
$writer->writeElement('height', '60'); 
    
$writer->endElement(); 
//---------------------------------------------------- 



//---------------------------------------------------- 
$writer->startElement("item"); 
$writer->writeElement('title', 'New Product 8'); 
$writer->writeElement('link', 'http://www.domain.com/link.htm'); 
$writer->writeElement('description', 'Description 8 Yeah!'); 
$writer->writeElement('guid', 'http://www.domain.com/link.htm?tiem=1234'); 

$writer->writeElement('pubDate', date("D, d M Y H:i:s e")); 

$writer->startElement('category'); 
    
$writer->writeAttribute('domain', 'http://www.domain.com/link.htm'); 
    
$writer->text('May 2008'); 
$writer->endElement(); // Category 

// End Item 
$writer->endElement(); 
//---------------------------------------------------- 


// End channel 
$writer->endElement(); 

// End rss 
$writer->endElement(); 

$writer->endDocument(); 

$writer->flush(); 
?>
The above will give you this:

Code:
 <?xml version="1.0"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Latest Products</title>
<description>This is the latest products from our website.</description>
<link>http://www.domain.com/link.htm</link>
<pubDate>Thu, 10 Jul 2008 11:47:14 GMT</pubDate>
<image>
<title>Latest Products</title>
<link>http://www.domain.com/link.htm</link>
<url>http://www.iab.net/media/image/120x60.gif</url>
<width>120</width>
<height>60</height>
</image>
<item>
<title>New Product 8</title>
<link>http://www.domain.com/link.htm</link>
<description>Description 8 Yeah!</description>
<guid>http://www.domain.com/link.htm?tiem=1234</guid>
<pubDate>Thu, 10 Jul 2008 11:47:14 GMT</pubDate>
<category domain="http://www.domain.com/link.htm">May 2008</category>
</item>
</channel>
</rss>

generating xml using XmlWrite class

<?php


class XmlWriter {
var $xml;
var $indent;
var $stack = array();
function XmlWriter($indent = ' ') {
$this->indent = $indent;
$this->xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
}
function _indent() {
for ($i = 0, $j = count($this->stack); $i < $j; $i++) {
$this->xml .= $this->indent;
}
}
function push($element, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.$element;
foreach ($attributes as $key => $value) {
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
}
$this->xml .= ">\n";
$this->stack[] = $element;
}
function element($element, $content, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.$element;
foreach ($attributes as $key => $value) {
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
}
$this->xml .= '>'.htmlentities($content).'</'.$element.'>'."\n";
}
function emptyelement($element, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.$element;
foreach ($attributes as $key => $value) {
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
}
$this->xml .= " />\n";
}
function pop() {
$element = array_pop($this->stack);
$this->_indent();
$this->xml .= "</$element>\n";
}
function getXml() {
return $this->xml;
}
}

/* Test

$xml = new XmlWriter();
$array = array(
array('monkey', 'banana', 'Jim'),
array('hamster', 'apples', 'Kola'),
array('turtle', 'beans', 'Berty'),
);

$xml->push('zoo');
foreach ($array as $animal) {
$xml->push('animal', array('species' => $animal[0]));
$xml->element('name', $animal[2]);
$xml->element('food', $animal[1]);
$xml->pop();
}
$xml->pop();

print $xml->getXml();

*/
?>

Perlmod is a program that will help you manage Perl Modules.

http://sourceforge.net/projects/perlmod/files/latest/download

A Perl module is a discrete component of software for the Perl
programming language. Technically, it is a particular set of
conventions for using Perl's package mechanism that has become
universally adopted.[discuss] A module defines its source code to be
in a package (much like a Java package), the Perl mechanism for
defining namespaces, e.g. CGI or Net::FTP or XML::Parser; the file
structure mirrors the namespace structure (e.g. the source code for
Net::FTP is in Net/FTP.pm). Furthermore, a module is the Perl
equivalent of the class when object-oriented programming is employed

Now we'll see an easy way to manage them, install, list, delete
(uninstall) from the command line.


Perlmod is a program that will help you manage Perl Modules.

Other Articles

Enter your email address: