Welcome to Dream.In.Code
Become an Expert!

Join 149,512 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,364 people online right now. Registration is fast and FREE... Join Now!




Youtube XML

 
Reply to this topicStart new topic

Youtube XML

haveacigar
16 Jul, 2007 - 03:47 AM
Post #1

New D.I.C Head
*

Joined: 3 Feb, 2007
Posts: 15


My Contributions
Hi, For the past few days I have been trying to get my favorited youtube videos integrated into my site. However i wanted it to automatically change when I favorite a video. I dont know that much about xml so i thought id have a go at w3schools, but after reading the documentation i couldnt get it to work. So im not sure if it is because the youtube link doesnt have an .xml extention or if it is because i am going about it the wrong way.


this is the code, and again I am not to good with javascript, so this is pretty much straight from the w3 site.
CODE


<script type="text/javascript">
var xmlDoc;
function loadXML()
{
// code for IE
if (window.ActiveXObject)
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async=false;
  xmlDoc.load("http://www.youtube.com/api2_rest?method=youtube.users.list_favorite_videos&dev_id=7s7JSE1L76s&user=haveacigaro");
  getmessage();
  }
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation &&
document.implementation.createDocument)
  {
  xmlDoc=document.implementation.createDocument("","",null);
  xmlDoc.load("http://www.youtube.com/api2_rest?method=youtube.users.list_favorite_videos&dev_id=7s7JSE1L76s&user=haveacigaro");
  xmlDoc.onload=getmessage;
  }
else
  {
  alert('Your browser cannot handle this script');
  }
}

function getmessage()
{
document.getElementById("author").innerHTML=
xmlDoc.getElementsByTagName("author")[0].childNodes[0].nodeValue;
document.getElementById("title").innerHTML=
xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
document.getElementById("thumbnail_url").innerHTML=
xmlDoc.getElementsByTagName("tags")[0].childNodes[0].nodeValue;
}
</script>



cheers for any help
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 07:39PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month