PHP XML parser function

Source: Internet
Author: User
Tags processing instruction xml parser

PhpXML Parser Functions Introduction to PHP XML Parser

XML functions allow you to parse an XML document, but you cannot validate it.

XML is a data format used for standard structured document exchange. You can find more information about XML in our XML tutorials.

The extension uses the Expat XML parser.

Expat is an event-based parser that treats XML documents as a series of events. When an event occurs, it invokes a specified function to process it.

Expat is a non-validated parser that ignores any DTD that is linked to a document. However, if the document does not form well, it ends with an error message.

Because it is an event-based, non-validated parser, Expat has features that are fast and appropriate for WEB applications.

The XML parser function allows you to create an XML parser and define a handle for an XML event.


The XML Parser function is part of the PHP core. These functions can be used without installation.

PHP XML Parser function

php: Indicates the earliest version of PHP that supports this function.

function Description PHP
Utf8_decode () Decodes the UTF-8 string to iso-8859-1. 3
Utf8_encode () Encode the iso-8859-1 string as UTF-8. 3
Xml_error_string () Gets the error string for the XML parser. 3
Xml_get_current_byte_index () Gets the current byte index of the XML parser. 3
Xml_get_current_column_number () Gets the current column number of the XML parser. 3
Xml_get_current_line_number () Gets the current line number of the XML parser. 3
Xml_get_error_code () Gets the error code for the XML parser. 3
Xml_parse () Parse the XML document. 3
Xml_parse_into_struct () Parse the XML data into an array. 3
Xml_parser_create_ns () Creates an XML parser with namespace support. 4
Xml_parser_create () Create an XML parser. 3
Xml_parser_free () Releases the XML parser. 3
Xml_parser_get_option () Gets the options from the XML parser. 3
Xml_parser_set_option () Set options for the XML parser. 3
Xml_set_character_data_handler () Establishes the character data processor. 3
Xml_set_default_handler () Establishes the default processor. 3
Xml_set_element_handler () Establishes the start and end element processors. 3
Xml_set_end_namespace_decl_handler () Establishes the terminating namespace declaration processor. 4
Xml_set_external_entity_ref_handler () Create an external entity processor. 3
Xml_set_notation_decl_handler () Establishes the symbolic declaration processor. 3
Xml_set_object () Use an XML parser in an object. 4
Xml_set_processing_instruction_handler () Establishes the processing instruction (PI) processor. 3
Xml_set_start_namespace_decl_handler () Establishes the start namespace declaration processor. 4
Xml_set_unparsed_entity_decl_handler () Establishes an unresolved entity declaration processor. 3

PHP XML Parser Constants

Xml_error_none (integer)
Xml_error_no_memory (integer)
Xml_error_syntax (integer)
Xml_error_no_elements (integer)
Xml_error_invalid_token (integer)
Xml_error_unclosed_token (integer)
Xml_error_partial_char (integer)
Xml_error_tag_mismatch (integer)
Xml_error_duplicate_attribute (integer)
Xml_error_junk_after_doc_element (integer)
Xml_error_param_entity_ref (integer)
Xml_error_undefined_entity (integer)
Xml_error_recursive_entity_ref (integer)
Xml_error_async_entity (integer)
Xml_error_bad_char_ref (integer)
Xml_error_binary_entity_ref (integer)
Xml_error_attribute_external_entity_ref (integer)
Xml_error_unknown_encoding (integer)
Xml_error_incorrect_encoding (integer)
Xml_error_unclosed_cdata_section (integer)
Xml_error_external_entity_handling (integer)
Xml_option_case_folding (integer)
Xml_option_target_encoding (integer)
Xml_option_skip_tagstart (integer)
Xml_option_skip_white (integer)

PHP XML parser function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.