title: Youtube API get video duration from the XML
body: <p>Consider Youtube API XML files like <a href="http://gdata.youtube.com/feeds/api/videos/" rel="nofollow">http://gdata.youtube.com/feeds/api/videos/</a>$id
  One particular XML data file is <a href="http://gdata.youtube.com/feeds/api/videos/GI6CfKcMhjY" rel="nofollow">http://gdata.youtube.com/feeds/api/videos/GI6CfKcMhjY</a>
  The following function gets the title of the video according to the XML url:</p>
  
  <pre><code>function ytTitle($ytid,$ytURLConstant){
      $url = $ytURLConstant.$ytid;
      $doc = new DOMDocument;
      $doc-&gt;load($url);
      echo $title = $doc-&gt;getElementsByTagName("title")-&gt;item(0)-&gt;nodeValue;
  }
  </code></pre>
  
  <p>As I see there is video duration in the XML file:</p>
  
  <pre><code>&lt;media:title type='plain'&gt;Jack Sparrow (feat. Michael Bolton)&lt;/media:title&gt;&lt;yt:duration seconds='197'/&gt;
  </code></pre>
  
  <p>As I am an XML newbie any help concerning getting the video duration will be greatly appreciated.</p>