PHP 函数 xml_parser_create_ns()

定义和用法

函数 xml_parser_create_ns() 创建带有命名空间支持的 XML 解析器。

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, the encoding of the input XML is automatically detected, so 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 for output is ISO-8859-1, while PHP 5.0.2 and above versions are 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);
?>