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

  • Home
  • SEARCH
  • 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 7401573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:30:31+00:00 2026-05-29T04:30:31+00:00

Possible Duplicate: Parse XML with Namespace using SimpleXML PHP SimpleXML Namespace Problem <?php header(Content-Type:

  • 0

Possible Duplicate:
Parse XML with Namespace using SimpleXML
PHP SimpleXML Namespace Problem

<?php
header("Content-Type: text/html; charset=utf-8");
$str = <<<ETO
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:bc="http://www.brightcove.tv/link" xmlns:dcterms="http://purl.org/dc/terms/">
    <channel>
        <item>
            <title>Press Conference with Chairman of the FOMC, Ben S. Bernanke</title>
            <link>http://link.brightcove.com/services/link/bcpid720309829001/bctid1414417812001?src=mrss</link>
            <description>Chairman of the FOMC, Ben S. Bernanke, Washington, D.C.</description>
            <pubDate>Thu, 26 Jan 2012 11:57:19 -0800</pubDate>
            <media:player height="580" url="http://link.brightcove.com/services/link/bcpid720309829001/bctid1414417812001?src=mrss" width="440"/>
            <media:thumbnail height="90" url="http://brightcove.vo.llnwd.net/d20/unsecured/media/66043936001/66043936001_1414432575001_fomc-presser-thumb.jpg?pubId=66043936001" width="120"/>
            <media:thumbnail height="360" url="http://brightcove.vo.llnwd.net/d20/unsecured/media/66043936001/66043936001_1414432069001_fomc-presser-large.jpg?pubId=66043936001" width="480"/>
            <bc:duration>4016</bc:duration>
        </item>
        <item>
            <title>Press Conference with Chairman of the FOMC, Ben S. Bernanke</title>
            <link>http://link.brightcove.com/services/link/bcpid720309829001/bctid1258170578001?src=mrss</link>
            <description>Chairman of the FOMC, Ben S. Bernanke, Washington, D.C.</description>
            <pubDate>Thu, 26 Jan 2012 08:21:02 -0800</pubDate>
            <media:player height="580" url="http://link.brightcove.com/services/link/bcpid720309829001/bctid1258170578001?src=mrss" width="440"/>
            <media:thumbnail height="90" url="http://brightcove.vo.llnwd.net/d16/unsecured/media/66043936001/66043936001_1014046968001_DSC-95132.jpg?pubId=66043936001" width="120"/>
            <media:thumbnail height="360" url="http://brightcove.vo.llnwd.net/d16/unsecured/media/66043936001/66043936001_1014127979001_DSC-95132.jpg?pubId=66043936001" width="480"/>
            <bc:duration>2897</bc:duration>
        </item>
    </channel>
</rss>
ETO;
$xmlObj = simplexml_load_string($str);
foreach($xmlObj->channel->item as $item){
    echo $item->title.'<br />';
    echo $item->link.'<br />';
    echo $item->description.'<br />';
    echo $item->pubDate.'<br />';
    echo $item->xpath('media:player').'<br />';
    echo $item->xpath('media:thumbnail',0)->url.'<br />';
    echo $item->xpath('media:thumbnail',1)->url.'<br />';
    echo $item->xpath('bc:duration').'<br />';
    echo '<hr />';
}
?>

How to parse some node like media:player,media:thumbnail, bc:duration? I met some wrong, 2 string array and 2 wrong…

Array
Warning: SimpleXMLElement::xpath() expects exactly 1 parameter, 2 given in E:\www\1.php on line 37 
Warning: SimpleXMLElement::xpath() expects exactly 1 parameter, 2 given in E:\www\1.php on line 39 
Array
  • 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-29T04:30:31+00:00Added an answer on May 29, 2026 at 4:30 am

    This gets you, what you want:

    $hlp = $item->xpath('media:thumbnail[1]');
    echo $hlp[0]['url'];
    

    Maybe, there are better methods…I’ll see, if I can find some.

    Regarding the errormessage, ThinkingMonkey is right – you used the function incorrectly.

    —

    edit: This is probably a faster and more beautiful solution:

    $media = $item->children('http://search.yahoo.com/mrss/');
    $hlp = $media->player->attributes();
    echo $hlp['url'].'<br />';
    $hlp = $media->thumbnail[0]->attributes();
    echo $hlp['url'].'<br />';
    $hlp = $media->thumbnail[1]->attributes();
    echo $hlp['url'].'<br />';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to parse and process HTML/XML with PHP? I want to grab
Possible Duplicate: How to parse and process HTML with PHP? $content = <p>This is
Possible Duplicate: How to parse HTML with PHP? Get MySQL database output via PHP
Possible Duplicate: How to parse and process HTML with PHP? Here is what I'm
Possible Duplicate: How to extract a node attribute from XML using PHP's DOM Parser
Possible Duplicate: How to parse and process HTML with PHP? I'm looking into HTML
Possible Duplicate: Parsing XML in Cocoa iPhone - Can we parse .plist(xml) file using
Possible Duplicate: How to parse HTML with PHP? Grabbing the href attribute of an
Possible Duplicate: How to parse HTML with PHP? I would be most grateful if
Possible Duplicate: How to parse HTML with PHP? i want to write a php-program

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.