xml_parser_create_ns()

xml_parser_create_ns() — Create an XML parser with namespace support.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.5, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

xml_parser_create_ns() creates a new XML parser with XML namespace support and returns a XMLParser instance to be used by the other XML functions.

Signature

xml_parser_create_ns(?string $encoding = null, string $separator = ":"): XMLParser

Parameters

ParameterTypeWhat it takes
$encoding?stringThe input encoding is automatically detected, so that the encoding parameter specifies only the output encoding. The default output charset is UTF-8. The supported encodings are ISO-8859-1, UTF-8 and US-ASCII.
$separatorstringWith a namespace aware parser tag parameters passed to the various handler functions will consist of namespace and tag name separated by the string specified in separator.

Return value

Returns a new XMLParser instance.

Example

The PHP manual ships no example for xml_parser_create_ns(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.0.0This function returns an XMLParser instance now; previously, a resource was returned, or false on failure.
8.0.0encoding is nullable now.

See also

xml_parser_create()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page xml_parser_create_ns() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.