Libxml Functions in PHP

PHP libxml Introduction :

  • The libxml functions and constants are used together with SimpleXML, XSLT and DOM functions.

Installation :

These functions require the libxml package. Download at xmlsoft.org

PHP libxml Functions :

  • PHP: indicates the earliest version of PHP that supports the function.
Function Description
libxml_clear_errors() Clear libxml error buffer
libxml_get_errors() Retrieve array of errors
libxml_get_last_error() Retrieve last error from libxml
libxml_set_streams_context() Set the streams context for the next libxml document load or write
libxml_use_internal_errors() Disable libxml errors and allow user to fetch error information as needed

PHP 5 Predefined libxml Constants :

Function Description
LIBXML_COMPACT Set small nodes allocation optimization. This may improve the application performance
LIBXML_DTDATTR Set default DTD attributes
LIBXML_DTDLOAD Load external subset
LIBXML_DTDVALID Validate with the DTD
LIBXML_NOBLANKS Remove blank nodes
LIBXML_NOCDATA Set CDATA as text nodes
LIBXML_NOEMPTYTAG Change empty tags (e.g. <br/> to <br></br>), only available in the DOMDocument->save() and DOMDocument->saveXML() functions
LIBXML_NOENT Substitute entities
LIBXML_NOERROR Do not show error reports
LIBXML_NONET Stop network access while loading documents
LIBXML_NOWARNING Do not show warning reports
LIBXML_NOXMLDECL Drop the XML declaration when saving a document
LIBXML_NSCLEAN Remove excess namespace declarations
LIBXML_XINCLUDE Use XInclude substitution
LIBXML_ERR_ERROR Get recoverable errors
LIBXML_ERR_FATAL Get fatal errors
LIBXML_ERR_NONE Get no errors
LIBXML_ERR_WARNING Get simple warnings
LIBXML_VERSION Get libxml version (e.g. 20605 or 20617)
LIBXML_DOTTED_VERSION Get dotted libxml version (e.g. 2.6.5 or 2.6.17)