توابع xml_parser_create() پی‌ه‌پ‌ه

Definition and Usage

The xml_parser_create() function creates an XML parser.

This function creates a new XML parser and returns a resource handle that can be used by other XML functions.

Syntax

xml_parser_create(encoding)
Parameter Description
encoding Optional. Specifies the output encoding.

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(); Functions.

Tip:To create an XML parser that supports namespaces, use xml_parser_create_ns(); Functions.

Examples

<?php
$xmlparser = xml_parser_create();;
xml_parser_free($xmlparser);
?>