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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:09:09+00:00 2026-05-27T06:09:09+00:00

I am getting the following PHP Fatal Error Fatal error: Uncaught exception ‘Exception’ with

  • 0

I am getting the following PHP Fatal Error

Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’ in Stack trace …

And the error log is pointing to the line

$xml = new SimpleXMLElement($data);

(which is the very next line after the code except below) as the culprit.

However, when I run each feed individually, there is no error and the feed saves to the database.

This is the code that produces the error:

$feeds = array( 
     'http://www.mtv.com/rss/news/news_full.jhtml',
     'http://www.musicweek.com/rss.asp?navcode=232',
     'http://www.cmt.com/rss/news/latestcached.jhtml',
     'http://www.billboard.com/rss/news',
 );

foreach ($feeds as $feed)
{
    $ch = curl_init();

     // causes error:
    curl_setopt($ch, CURLOPT_URL, $feed);

    // works:
    curl_setopt($ch, CURLOPT_URL, 'http://www.billboard.com/rss/news');

    curl_setopt($ch, CURLOPT_HEADER, 0 );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch); // put data from rss url into variable
    curl_close($ch);
    ...

If I switch the commented lines and use the $feed variable, error and white page. It worked fine before this afternoon, so I am suspecting that there is something that is XML illegal in one of the feeds triggering this.

Is there a better way to write this -or- some way to catch the exception if necessary?

  • 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-27T06:09:10+00:00Added an answer on May 27, 2026 at 6:09 am

    The culprit is http://www.mtv.com/rss/news/news_full.jhtml . If you load the page, you get a lovely error. Here’s Chrome’s:

    This page contains the following errors:

    error on line 296 at column 38: Opening and ending tag mismatch:
    shorthead line 0 and i Below is a rendering of the page up to the
    first error.

    The faulty line in question currently reads:

    <shorthead>Big K.R.I.T. Promises </i>Live From The Underground<i> In Early 2012</shorthead>
    

    No surprise that it failed at all.


    As for catching the error, wrap your code in

    try {
         //... your code ...
    } catch(Exception $exception){
         //. . . Do somethign with exception ... 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fatal error: Uncaught exception 'ImagickDrawException' with message 'The given font is not found in
I'm using PHP 5.2 and getting the following error message: Fatal error: Call to
Am getting following error message on calling WCF service: The formatter threw an exception
I'm getting the following error message: Warning: file_get_contents( http://localhost/sample_pie.php ) [function.file-get-contents]: failed to open
I'm having a little issue with Doctrine. Im getting the following error: PHP Fatal
I am getting following error message when using Doctrine ORM in Codeigniter. ( !
Using the Facebook PHP SDK, I'm getting the following error when I try to
I keep on getting this error when running one of my scripts; PHP Fatal
I am using CakePHP and getting the following error Warning: Cache not configured properly.
I'm getting the following message for some php I have to use but did

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.