PHP libxml functions

PHP libxml Introduction

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

Installation

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

PHP libxml functions

PHP:Indicate the earliest PHP version that supports this function.

Function Description PHP
libxml_clear_errors() Clear libxml error buffer. 5
libxml_get_errors() Retrieve the error array. 5
libxml_get_last_error() Retrieve the last error from libxml. 5
libxml_set_streams_context() Set stream context for the next libxml document loading or writing. 5
libxml_use_internal_errors() Disable libxml errors, allowing users to read error information as needed. 5

PHP libxml constants

Function Description PHP
LIBXML_COMPACT Set small node allocation optimization. It will improve the performance of the application. 5
LIBXML_DTDATTR Set default DTD attributes. 5
LIBXML_DTDLOAD Load external subsets. 5
LIBXML_DTDVALID Validate through DTD. 5
LIBXML_NOBLANKS Delete empty nodes. 5
LIBXML_NOCDATA Set CDATA as text node. 5
LIBXML_NOEMPTYTAG

Change empty tags (e.g., <br/> to <br></br>).

Available only in DOMDocument->save() and DOMDocument->saveXML() functions.

5
LIBXML_NOENT Substitute entities. 5
LIBXML_NOERROR Do not display error reports. 5
LIBXML_NONET Stop network access when loading the document. 5
LIBXML_NOWARNING Do not display warning reports. 5
LIBXML_NOXMLDECL Undo XML declaration when saving the document. 5
LIBXML_NSCLEAN Remove additional namespace declarations. 5
LIBXML_XINCLUDE Use XInclude replacement. 5
LIBXML_ERR_ERROR Get recoverable errors. 5
LIBXML_ERR_FATAL Get fatal errors. 5
LIBXML_ERR_NONE Get no errors. 5
LIBXML_ERR_WARNING Get simple warnings. 5
LIBXML_VERSION Get the libxml version (e.g., 20605 or 20617). 5
LIBXML_DOTTED_VERSION Get the dotted libxml version (e.g., 2.6.5 or 2.6.17). 5