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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:13:15+00:00 2026-06-08T09:13:15+00:00

I have the following code to read in an XML file: $xml2 = simplexml_load_file(‘http://www.facebook.com/feeds/page.php?format=rss20&id=334704593230758’);

  • 0

I have the following code to read in an XML file:

$xml2 = simplexml_load_file('http://www.facebook.com/feeds/page.php?format=rss20&id=334704593230758'); 
$item = $xml2->channel->item;

I am getting the following back in my source code:

<b>Warning</b>:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: http://www.facebook.com/feeds/page.php?format=rss20&amp;id=334704593230758:11: parser error : xmlParseEntityRef: no name in <b>/home/content/49/8644249/html/test/_inc/footer.php</b> on line <b>110</b><br />

it continues on like that for 10 more lines. Is there a problem with the xml code?

  • 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-06-08T09:13:17+00:00Added an answer on June 8, 2026 at 9:13 am

    OK, slightly weirdly since this is an RSS feed and not designed to be directly human-readable, the answer to this is that you have to include a User-Agent: header in your request.

    When I load the URL in Chrome a get valid XML document, when I run you code I get the same errors you do. Upon closer inspection I find that when I run your code I actually get a minimal HTML document back, not the desired XML – in order to get the right result you have to pass a valid user agent string, which means you can’t use simplexml_load_file() because it doesn’t support stream contexts.

    This code works for me:

    // User-Agent string from Chrome. I haven't tested anything else so I don't know
    // what is actually required, but this works.
    $context = stream_context_create(array(
      'http'=>array(
        'user_agent' => 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11'
       )
    ));
    
    // Get data as a string
    $xml2 = file_get_contents('http://www.facebook.com/feeds/page.php?format=rss20&id=334704593230758', FALSE, $context);
    
    // Convert string to a SimpleXML object
    $xml2 = simplexml_load_string($xml2);
    
    $item = $xml2->channel->item;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML file with page nodes which I want to read
Hi i have the following code to read the xml file and change the
When I using the following code to read file: lines=file(data.txt).read().split(\n) I have the following
I have written the following piece of code that reads through a given xml-file
I have the following code to read a text file. const string FILENAME =
I have the following code: import re #open the xml file for reading: file
Following is my code along with the xml file i have 2 table layouts
I have the following code: $SQL = UPDATE jobs SET read = '1' WHERE
I have the following code: f = open(path, 'r') html = f.read() # no
i have the following code: <p class=more><a href=/stories class=more>Read more</a></p> and CSS: a.more, a.back

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.