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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:45:09+00:00 2026-05-12T11:45:09+00:00

I have a page that will basically be used to concatenate a bunch of

  • 0

I have a page that will basically be used to concatenate a bunch of xml files, it will act as glue that binds them together. There’s a small chance the xml files that are being combined might not be well formed because the user will have access.

I’m trying to basically rewrite a live file if there are no warnings / errors thrown in a specific set of code.

So far I have:

try {
    $first = simplexml_load_file( 'file.xml' );
} catch ( Exception $e ) {
    $write = false;
}

if ( !$write ) { 
// write to live file.
}

This obviously catches error exceptions, but sometimes function invocations can return warnings and not errors per se, what can I use to catch errors, basically only write if no warnings and errors have been thrown in the try block?

Example of a warning being thrown:

Warning: simplexml_load_file() parser error : Start tag expected, '<'
  • 1 1 Answer
  • 1 View
  • 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-12T11:45:09+00:00Added an answer on May 12, 2026 at 11:45 am

    Just look for other "symptoms" of a failed read. From the simplexml_load_file manual entry:

    Return Values

    Returns an object of class SimpleXMLElement with properties containing the data held within the XML document. On errors, it will return FALSE.

    So, use it like this:

    $first = simplexml_load_file( 'file.xml' );
    
    if ($first == false) {
        echo "File couldn't be loaded";
        exit(); // abort normal program execution, redirect or what have you
    }
    
    // continue as normal
    

    Almost all functions return some sort of false in case of an error. You shouldn’t use manual "error parsing" except for very special cases. This isn’t one of them.

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

Sidebar

Related Questions

I have a page that will have a full size product image and 4
I have an ASP.Net page that will be hosted on a couple different servers,
I have an asp.net page that calls a dll that will start a long
I have a button on an ASP.Net page that will call Response.Redirect back to
I have to do a asp.net web page that when load will say something
I am loading content into a page with ajax that will have live click
in my application i have the playvideo page where video will play, below that
I have a page that is generated which inserts an HTML comment near the
I have a page that uses $(id).show(highlight, {}, 2000); to highlight an element when
Sorry for this question. Basically I have a page where I have it automatically

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.