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 6241697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:48:53+00:00 2026-05-24T11:48:53+00:00

I have problems parsing a atom facebook feed. Using: PHP’s DOMDocument. Errors: Warning: DOMDocument::loadXML():

  • 0

I have problems parsing a atom facebook feed.

Using:

PHP’s DOMDocument.

Errors:

Warning: DOMDocument::loadXML(): xmlParseEntityRef: no name in Entity, line: 12
Warning: DOMDocument::loadXML(): xmlParseEntityRef: no name in Entity, line: 12
Warning: DOMDocument::loadXML(): Entity ‘euro’ not defined in Entity, line: 16
Warning: DOMDocument::loadXML(): Entity ‘acute’ not defined in Entity, line: 16
Warning: DOMDocument::loadXML(): Entity ‘euro’ not defined in Entity, line: 16
Warning: DOMDocument::loadXML(): Entity ‘acute’ not defined in Entity, line: 16
Notice: Trying to get property of non-object in … on line 76

Unfortunately, the entities mentioned above cannot be found in feed code. Not that simple… The problem has to be something different. Other feeds can be parsed using the same code without any problems. So, I think the problem is something in Facebook’s HTML inside the content tag. What could this be? How to solve?

    <content type="html">&lt;div class=&quot;ext_media clearfix has_extra has_thumb&quot;&gt;&lt;div class=&quot;title&quot;&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=BPq58p0K6DM&amp;feature=youtu.be&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot; title=&quot;http://www.youtube.com/watch?v=BPq58p0K6DM&amp;amp;feature=youtu.be&quot; onmousedown=&quot;UntrustedLink.bootstrap($(this), &quot;-AQBiGfHA&quot;, event, bagof(null));&quot;&gt;Did you know there were this many satellites in orbit VIDEO&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;url&quot;&gt;Quelle: www.youtube.com&lt;/div&gt;&lt;div class=&quot;story_posted_item clearfix&quot;&gt;&lt;div class=&quot;extra&quot;&gt;&lt;div class=&quot;share_thumb&quot;&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=BPq58p0K6DM&amp;feature=youtu.be&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot; onmousedown=&quot;UntrustedLink.bootstrap($(this), &quot;2AQBCjOTV&quot;, event, bagof(null));&quot;&gt;&lt;img class=&quot;img_loading img&quot; src=&quot;http://i3.ytimg.com/vi/BPq58p0K6DM/default.jpg&quot; alt=&quot;&quot; onload=&quot;var img = this; onloadRegister(function() { adjustImage(img); });&quot; id=&quot;share_thumb_257759307568958&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content>

See the full feed code here. (See feed in browser.)

Full PHP code that I am using:

    $feed_xml_str = ...;

print '<pre>';
print_r( xmlstr_to_array($feed_xml_str) );
print '</pre>';

function xmlstr_to_array($xmlstr) {
    $doc = new DOMDocument();
    $doc->loadXML($xmlstr);
    return domnode_to_array($doc->documentElement);
}
function domnode_to_array($node) {
    $output = array();
    switch ($node->nodeType) {
        case XML_CDATA_SECTION_NODE:
        case XML_TEXT_NODE:
            $output = trim($node->textContent);
            break;
        case XML_ELEMENT_NODE:
            for ($i=0, $m=$node->childNodes->length; $i<$m; $i++) {
                $child = $node->childNodes->item($i);
                $v = domnode_to_array($child);
                if(isset($child->tagName)) {
                    $t = $child->tagName;
                    if(!isset($output[$t])) {
                        $output[$t] = array();
                    }
                    $output[$t][] = $v;
                }
                elseif($v) {

                    // >>>>> WJ: OUT COMMENTED CODE >>>>>
                    //$output = (string) $v;
                    // >>>>> WJ: ADDED CODE >>>>>
                    if($node->attributes->length) {
                        $a = array();
                        foreach($node->attributes as $attrName => $attrNode) {
                            $a[$attrName] = (string) $attrNode->value;
                        }
                        $output['@attributes'] = $a;
                        $output['@value'] = (string) $v;
                    }
                    else
                        $output = (string) $v;
                    // >>>>> WJ: MODIFIED CODE END >>>>>

                }
            }
            if(is_array($output)) {
                if($node->attributes->length) {
                    $a = array();
                    foreach($node->attributes as $attrName => $attrNode) {
                        $a[$attrName] = (string) $attrNode->value;
                    }
                    $output['@attributes'] = $a;
                }
                foreach ($output as $t => $v) {
                    if(is_array($v) && count($v)==1 && $t!='@attributes') {
                        $output[$t] = $v[0];
                    }
                }
            }
            break;
    }
    return $output;
}
  • 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-24T11:48:54+00:00Added an answer on May 24, 2026 at 11:48 am

    Facebook is sniffing user-agents, and won’t give you the XML feed you see in a browser without giving one. You can handle this several ways before fetching the XML from their server:

    ini_set("user_agent","my_awesome_magic_user_agent_which_can_be_anyhing");
    

    Or:

    stream_context_set_default(
         array(
            "http"=>array(
               "user_agent"=>"whatever"  
             )
         ));
    

    Next time, you might want to echo your XML string to see what is really going on….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've worked on several PHP projects and always I have problems with organizing my
I am having some problems parsing this piece of XML using SimpleXML. There is
I have memory problems with the webapp responsible from parsing XML event and pushing
I have problems with bringing a windows mobile 6 form to the front. I
I frequently have problems dealing with DataRows returned from SqlDataAdapters . When I try
I seem to always have problems with converting data to and from XML in
I have some problems with Miktex installed on Windows Vista Business SP1/32 bit. I
I have some problems on a site with the concurrent access to a list.
Does anyone have any problems with VS2008 on Vista? For me every so often
I am very new to C and I have some problems learning about pointers.

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.