Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6325207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:51:06+00:00 2026-05-24T16:51:06+00:00

I have an xml feed from the youtube API. So far I have successfully

  • 0

I have an xml feed from the youtube API. So far I have successfully lifted the title,thumbnail, ratings etc. However I am struggling to parse the content url from the following feed.

<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/'>
<entry>
<media:group>
<media:content url='http://www.youtube.com/v/ZTUVgYoeN_b?f=gdata_standard...' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='215' yt:format='5'/>

<media:content url='rtsp://rtsp2.youtube.com/ChoLENy73bIAEQ1kgGDA==/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='215' yt:format='1'/>

<media:content url='rtsp://rtsp2.youtube.com/ChoLENy73bIDRQ1kgGDA==/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='215' yt:format='6'/>

</media:group>
</entry>
</feed>

Below is my code so far. I believe this has worked for other items because I was not selecting from multiple nodes i.e. there is only one title, thumbnail url etc…

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $xml_feed_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$xml = curl_exec($ch);
curl_close($ch);

$feed = produce_XML_object_tree($xml);
$entry = $feed->entry;
$media = $entry->children('http://search.yahoo.com/mrss/');
$urla=$media->content->attributes();
$url=$urla["url"];

function produce_XML_object_tree($raw_XML) 
{
libxml_use_internal_errors(true);
try 
    {
    $xmlTree = new SimpleXMLElement($raw_XML);
    } 
    catch (Exception $e) 
    {
    // Something went wrong.
    $error_message = 'SimpleXMLElement threw an exception.';
    foreach(libxml_get_errors() as $error_line) 
        {
        $error_message .= "\t" . $error_line->message;
        }

    trigger_error($error_message);
    return false;
    }
return $xmlTree;
}

How can I select one of these content types?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:51:06+00:00Added an answer on May 24, 2026 at 4:51 pm

    Solved

    To select one of the content types I just had to use a simple index. Hopefully this is a lesson I only need to learn once:

    $urla=$media->group->content[0]->attributes();
    $url=$urla["url"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml feed from Google Contacts API, but I have trouble reading
I have an xml feed which I need to access an element from. However,
Basically I have an xml feed from an offsite server. The xml feed has
I have a NSString which is passed from an xml feed........ NSString *strDate =@May
I have a NSString which is passed from an xml feed........ NSString *strDate =@Thu,
Have a WCF service (hosted in IIS 6.0) that takes an XML feed from
I have the following case. I import data from an xml feed and from
I have this xml. <?xml version=1.0 encoding=utf-8?> <feed xml:lang=el-gr xmlns=http://www.w3.org/2005/Atom> <title type=text>name.gr</title> <updated>2011-07-23</updated> <link
I have a call to a YouTube XML sheet that works perfectly fine. However,
I have a simple application, it starts, loads xml feed from the net, you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.