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
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']); 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.