Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to shut up simpleXML on malformed data? [duplicate]

Tags:

php

simplexml

I have a XML setting I am trying to load using simplexml. The XML setting can be edited by the user of a web application. I want to handle errors myself and dispatch a warning message to the user interface. However, simplexml keeps throwing warnings on malformed XML instead of quietly returning false.

How can I make simpleXML shut up and not throw a warning? Is there an option for that?

like image 798
Pekka Avatar asked Nov 04 '09 14:11

Pekka


1 Answers

Use libxml_use_internal_errors() to suppress XML errors.

You can then use libxml_get_errors() to inspect any errors if you need to.

like image 127
Ben James Avatar answered Sep 22 '22 09:09

Ben James