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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:53:03+00:00 2026-05-26T17:53:03+00:00

Simplexml fails with the following error message: simplexml_load_file(): fooo.xml:299108: parser error : Char 0xFFFE

  • 0

Simplexml fails with the following error message:

simplexml_load_file(): fooo.xml:299108: parser error : Char 0xFFFE out of allowed range

From my understanding, the complaint is about an invalid unicode character. Line 299108 doesn’t have “FFFE”, but it contains “EFBFBE”.

Is there way to handle this type of errors in simplexml?

  • 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-26T17:53:03+00:00Added an answer on May 26, 2026 at 5:53 pm

    I was running into this a lot with incoming user data, and I researched many methods to solve it. There are ways to properly encode the incoming data as UTF-8, without the higher-order (or other) unicode values that often cause these problems.

    However, the problem with the sanitizing solutions is that they change the data, and if you just want to be a middle man, you still want the output to contain these values. The only non-destructive way I could come up with to get a SimpleXMLElement reliably not fail, is to do this admittedly double-work solution:

        libxml_use_internal_errors(true);
        $dom = new DOMDocument("1.0", "UTF-8");
        $dom->strictErrorChecking = false;
        $dom->validateOnParse = false;
        $dom->recover = true;
        $dom->loadXML($xmlData);
        $xml = simplexml_import_dom($dom);
    
        libxml_clear_errors();
        libxml_use_internal_errors(false);
    

    The trick is in looking at the properties of DOMDocument in PHP’s documentation and noticing those extra variables that let you set parsing behavior. This method works without fail for me, on all the xml input that used to make SimpleXMLElement fail with character range issues.

    My only guess on why it works is that SimpleXMLElement does the strict checking on initialization, but not when being initialized from an existing DOMDocument.

    This method allows subsequent asXML() calls, without failure.

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

Sidebar

Related Questions

After initiating a new SimpleXml object: $xml = new SimpleXML($xmlStr); PHP errors out: Fatal
$xml = simplexml_load_file($xmlPath); $items = $xml->list->item; ... echo $items[$currentIndex]->asXML(); When I print out $currentIndex
Following suggestions on this site, I have adopted SimpleXML from org.simpleframework.xml. I use this
Is it possible to use PHP's SimpleXML functions to create an XML object from
I'm using a PHP script with SimpleXML to parse an XML feed. I have
I've been trying to use SimpleXML , but it doesn't seem to like XML
I'm building an XML document with PHP's SimpleXML extension, and I'm adding a token
I'm trying to parse an XML file using PHP, but I get an error
Im trying to build a simple XML to Controls parser in my CF application.
Using simplexml_load_string() how do I get ForgotPassword from the following XML? <?xml version=1.0 encoding=utf-8?>

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.