Graxeon Posted December 8, 2009 Share Posted December 8, 2009 I'm trying to get to "site.com/soccervideo.flv" within this XML file: <?xml version="1.0" encoding="utf-8"?> <playerconfig version="1.1"> <playlists> <playlist id=""> <items> <item id="soccervideo"> <videos> <video> <streams> <stream> <locations> <location seeking="yes"> http://site.com/soccervideo.flv </location> </locations> </stream> </streams> </video> </videos> </item> </items> </playlist> </playlists> </playerconfig> I tried this code but I get a blank page: <?php $url = $_GET['url']; $sxml = new SimpleXMLElement('http://site.com/embed/' .$url, NULL, TRUE); header("Location: {$sxml->playerconfig->playlists->playlist->items->videos->video->streams->stream->locations->location}"); ?> Help please? I'm not sure if this is the correct method of going about it. Quote Link to comment https://forums.phpfreaks.com/topic/184435-url-in-xml-file/ Share on other sites More sharing options...
Graxeon Posted December 8, 2009 Author Share Posted December 8, 2009 Can anyone see the problem? Quote Link to comment https://forums.phpfreaks.com/topic/184435-url-in-xml-file/#findComment-973677 Share on other sites More sharing options...
kopytko Posted December 8, 2009 Share Posted December 8, 2009 This should work: $sxml->playlists->playlist->items->item->videos->video->streams->stream->locations->location If there is more than one node in your xml, you can use array notation: $sxml->playlists[0]->playlist[0]->items[0]->item[0]->videos[0]->video[0]->streams[0]->stream[0]->locations[0]->location[0] Quote Link to comment https://forums.phpfreaks.com/topic/184435-url-in-xml-file/#findComment-973681 Share on other sites More sharing options...
Graxeon Posted December 8, 2009 Author Share Posted December 8, 2009 Worked, thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/184435-url-in-xml-file/#findComment-973686 Share on other sites More sharing options...
salathe Posted December 8, 2009 Share Posted December 8, 2009 You could also use XPath to grab the location nodes. $locations = $sxml->xpath('//location'); echo $locations[0]; Quote Link to comment https://forums.phpfreaks.com/topic/184435-url-in-xml-file/#findComment-973698 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.