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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:49:12+00:00 2026-06-17T22:49:12+00:00

I have in database several XML feeds which I regularly checking. How I do

  • 0

I have in database several XML feeds which I regularly checking. How I do process data:

I load these XML links from DB and in loop through the simplexml_load_file() I am parsing data.
But sometimes the script is terminated because of error caused by wrong format of XML file, for example:

Warning: simplexml_load_file() [function.simplexml-load-file]: URL_ADDRESS:1: parser error : Invalid XML encoding name in path_to_script on line 98

Warning: simplexml_load_file() [function.simplexml-load-file]: <?xml version="1.0" encoding=""?> in path_to_scriptp on line 98

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in path_to_script on line 98

Warning: Invalid argument supplied for foreach() in path_to_script on line 99

Is there any way to handle this error and when an error is occurred, then would be this XML feed skipped and the script would continue with the next one?

  • 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-17T22:49:13+00:00Added an answer on June 17, 2026 at 10:49 pm

    If simplexml_load_file­Docs fails to load the file, it will return false. If you use the LIBXML_NOERROR option­Docs, the error(s) won’t be reported either.

    So all you need to do is to check the return value:

    foreach ($files as $file)
    {
        $xml = simplexml_load_file($file, null, LIBXML_NOERROR);
    
        if ($xml === false) {
            continue;
        }
    
        ... process $xml ...
    }
    

    Online demo: http://codepad.viper-7.com/EXG7VP

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

Sidebar

Related Questions

I have to serialize several objects inheriting from WebControl for database storage. These include
I have heard from several sources that storing XML in a database is bad,
I have rows of hashes imported from several different XML database dumps that look
I have written an importer which copies data from a flat table into several
I have worked on several applications that saved XML data into a database. To
I have a database with several hundred tables imported from a third source. Using
I need to write some data in several database. I choose sqlapi.com I have
I have an Access database (in Access 2003) with several tables, and data must
I have a MySQL database that I am keeping temperature readings from several different
I currently have an iPhone app that reads data from an external XML file

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.