PHP xml_parser_create_ns() function
Definition and Usage
The xml_parser_create_ns() function creates an XML parser with namespace support.
This function creates a new XML parser and returns a resource handle that can be used by other XML functions.
Syntax
xml_parser_create_ns(encoding,separator)
Parameter | Description |
---|---|
encoding | Optional. Specifies the output encoding. |
encoding | Optional. Specifies the separator for the output of tag names and namespaces. The default is ":". |
Description
Optional Parameter encoding In PHP 4, used to specify the character encoding of the XML input to be parsed.
Starting with PHP 5, automatic detection of the encoding of the input XML is enabled, therefore encoding The parameter is used only to specify the encoding of the output data after parsing.
In PHP 4, the default output encoding is the same as the encoding of the input data. If an empty string is passed, the parser will try to search the first 3 or 4 bytes to determine the encoding of the document.
In PHP 5.0.0 and 5.0.1, the default character encoding of the output is ISO-8859-1, while for PHP 5.0.2 and above versions, it is UTF-8.
The encodings supported by the parser are ISO-8859-1, UTF-8, and US-ASCII.
Tips and Comments
Tip:To release the XML parser, use xml_parser_free(); Function.
Tip:To create an XML parser without namespace support, use xml_parser_create(); Function.
Example
<?php $xmlparser = xml_parser_create_ns();; xml_parser_free($xmlparser); ?>