Hello , I wanna make code to display the video thumbnail ,title ,author name and description . So i created code such as :- ------------------------------------------------------------------------------------------- <?php // set feed URL $feedURL = 'http://gdata.youtube.com/feeds/api/videos/sZE2ZBKhXGc'; // read feed into SimpleXML object $sxml = simplexml_load_file($feedURL); ?> <h1><?php echo $sxml->title; ?></h1><br> <?php // iterate over entries in feed foreach ($sxml->entry as $entry) { // get nodes in media: namespace for media information $media = $entry->children('http://search.yahoo.com/mrss/'); // get video player URL $attrs = $media->group->player->attributes(); $watch = $attrs['url']; // get video thumbnail $attrs = $media->group->thumbnail[0]->attributes(); $thumbnail = $attrs['url']; ?> <div class="item"> <span class="title"> <a href="<?php echo $watch; ?>"><?php echo $media->group->title; ?></a> </span> <p><?php echo $media->group->description; ?></p> <p> <span class="thumbnail"> <a href="<?php echo $watch; ?>"><img src="<?php echo $thumbnail;?>" /></a> <br/>click to view </span> <span class="attr">By:</span> <?php echo $entry->author->name; ?> </p> </div> <?php } ?> ------------------------------------------------------------------------------------------- So if u tested the code on your browser ,you will find that :- 1-this title query works <h1><?php echo $sxml->title; ?></h1><br> and the title has been displayed 2- this other queries didn't work <?php echo $media->group->title; ?> <?php echo $media->group->description; ?> <?php echo $thumbnail;?> <?php echo $entry->author->name; ?> So why that data didn't displayed , what is the mistake in the code and what have i do to fix it ??? Maybe somebody help me ??
so if i wanna display the video, video thumbnail ,title ,author name and description with the old preg_match how the code will be look like ??? beside i wish if anybody know how to fix my code
SimpleXML was made for the purpose of parsing xml... and works much better than using regular expressions
oh great , so if that code display the video title ---------------------------------------------------------------------- <?php // set feed URL $feedURL = 'http://gdata.youtube.com/feeds/api/videos/sZE2ZBKhXGc'; // read feed into SimpleXML object $sxml = simplexml_load_file($feedURL); ?> <h1><?php echo $sxml->title; ?></h1><br> ------------------------------------------------------------------------------------------- how can i make it display only the video description too ????