PHP Function Reference

PHP - libxml



These functions/constants are available as of PHP 5.1.0, and the following core extensions rely on this libxml extension: DOM, libxml, SimpleXML, SOAP, WDDX, XSL, XML, XMLReader, XMLRPC and XMLWriter.

Installation

There is no installation needed to use this extension. This extension is a part of the PHP core. This extension is enabled by default. It may be disabled by using the following option at compile time: --disable-libxml.

Runtime Configuration

This extension has no configuration directives defined in php.ini.

PHP libXMLError Class

ClassDescription
libXMLError Contains various information about errors thrown by libxml.

PHP libxml Functions

FunctionsDescription
libxml_clear_errors() Clears libxml error buffer.
libxml_disable_entity_loader() Disable the ability to load external entities.
libxml_get_errors() Retrieve array of errors.
libxml_get_last_error() Retrieve last error from libxml.
libxml_set_external_entity_loader() Changes the default external entity loader.
libxml_set_streams_context() Set the streams context for the next libxml document load or write.
libxml_use_internal_errors() Disables the standard libxml errors and enables user error handling.

PHP libxml Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

ConstantsTypeDescription
LIBXML_BIGLINESIntegerAllows line numbers greater than 65535 to be reported correctly.
LIBXML_COMPACTIntegerActivate small nodes allocation optimization. This may improve the application performance.
LIBXML_DTDATTRIntegerDefault DTD attributes.
LIBXML_DTDLOADIntegerLoad the external subset.
LIBXML_DTDVALIDIntegerValidate with the DTD.
LIBXML_HTML_NOIMPLIEDIntegerSets HTML_PARSE_NOIMPLIED flag, which turns off the automatic adding of implied html/body... elements.
LIBXML_HTML_NODEFDTDIntegerSets HTML_PARSE_NODEFDTD flag, which prevents a default doctype being added when one is not found.
LIBXML_NOBLANKSIntegerRemove blank nodes.
LIBXML_NOCDATAIntegerMerge CDATA as text nodes.
LIBXML_NOEMPTYTAGIntegerExpand empty tags (e.g. <br/> to <br></br>). This option is currently available in the DOMDocument::save and DOMDocument::saveXML functions.
LIBXML_NOENTInteger Substitute entities. Caution: Enabling entity substitution may facilitate XML External Entity (XXE) attacks.
LIBXML_NOERRORIntegerSuppress error reports.
LIBXML_NONETIntegerDisable network access when loading documents.
LIBXML_NOWARNINGIntegerSuppress warning reports.
LIBXML_NOXMLDECLIntegerDrop the XML declaration when saving a document.
LIBXML_NSCLEANIntegerRemove redundant namespace declarations.
LIBXML_PARSEHUGEIntegerSets XML_PARSE_HUGE flag, which relaxes any hard-coded limit from the parser. This affects limits like maximum depth of a document or the entity recursion, as well as limits of the size of text nodes.
LIBXML_PEDANTICIntegerSets XML_PARSE_PEDANTIC flag, which enables pedantic error reporting.
LIBXML_XINCLUDEIntegerImplement XInclude substitution.
LIBXML_ERR_ERRORIntegerA recoverable error.
LIBXML_ERR_FATALIntegerA fatal error.
LIBXML_ERR_NONEIntegerNo errors.
LIBXML_ERR_WARNINGIntegerA simple warning.
LIBXML_VERSIONIntegerlibxml version like 20605 or 20617.
LIBXML_DOTTED_VERSIONStringibxml version like 2.6.5 or 2.6.17.
LIBXML_SCHEMA_CREATEIntegerCreate default/fixed value nodes during XSD schema validation.