Jump to content

Retrieve URL from a XML file


Graxeon

Recommended Posts

If you know of a script or a tutorial that explains this (in TOTAL NEWBIE form), then please give me the link. I have checked this tutorial but can't make sense of it: http://www.phpfreaks.com/tutorial/handling-xml-data/page2

 

 

Ok so...

 

 

I would like to retrieve the url in this line:

 

<media:content url="http://content.movies.myspace.com/0020238/44/22/2023812244.flv" type="video/x-flv" medium="video" duration="221"/>

 

That line comes from this document:

 

http://mediaservices.myspace.com/services/rss.ashx?type=video&mediaID=8255294

 

I would like for that URL to be copied and brought back to the user in a form of redirecting.

 

So say I have this:

 

 

 

I do have this script (it's where I got the idea from) but cannot figure out how to alter it:

 

<?php
$url='http://mediaservices.myspace.com/services/rss.ashx?type=video&mediaID='.$_GET['video'];;
if ($details = file("$url"))
{
foreach($details as $value)
{
if(preg_match('/url=\"(.*?)\"/', $value, $match))
{
$myspace = $match[1];
}
}
header("Location: $myspace");
}
?>

Link to comment
https://forums.phpfreaks.com/topic/134937-retrieve-url-from-a-xml-file/
Share on other sites

<?php
  $url='http://mediaservices.myspace.com/services/rss.ashx?type=video&mediaID='.$_GET['video'];
  $sxml = simplexml_load_file($url);

  list($node) = $sxml->xpath('/rss/channel/item/media:content');
  header('Location: '.$node['url']); 
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.