ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: PHP :: PHP XML

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

PHP
PHP Libxml
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Mail
ÓÃPHP5µÄDirector..
PHP ×èÖ¹SQL×¢ÈëÊ..
PHP5ÃæÏò¶ÔÏó - »..
PHP5ÃæÏò¶ÔÏó - »..
PHP5ÃæÏò¶ÔÏó - »..
PHP5ÃæÏò¶ÔÏó - »..
PHP5ÃæÏò¶ÔÏó - »..
php5ÃæÏò¶ÔÏó - »..
php5ÃæÏò¶ÔÏó - »..
ÓÃPHP¿ØÖÆÓû§µÄä..
PHP PDO ѧϰ±Ê¼Ç

PHP XML


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ÐÞ¸Ä:2007-06-17 ä¯ÀÀ:5912 :: ::

PHP XML Parser Introduction
PHP XML Parser¼ò½é

The XML functions lets you parse, but not validate, XML documents.
XMLº¯Êý¿ÉÒÔ¶ÔXMLÎĵµ½øÐнâÎö£¬µ«ÊÇ£¬Ëû²»Äܹ»ÑéÖ¤XMLÎĵµµÄÓÐЧÐÔ¡£

XML is a data format for standardized structured document exchange. More information on XML can be found in our XML Tutorial.
XMLÊDZê×¼»¯µÄÓÃÀ´½»»»½á¹¹ÎĵµµÄÊý¾Ý¸ñʽ¡£Äã¿ÉÒԲ鿴ÎÒÃǵÄXML½Ì³ÌÀ´»ñÈ¡¸ü¶àµÄXMLÐÅÏ¢¡£

This extension uses the Expat XML parser.
ÕâÀïµÄÀ©Õ¹Ê¹ÓõÄÊÇExpat XML parser[Expat XML½âÎöÆ÷]

Expat is an event-based parser, it views an XML document as a series of events. When an event occurs, it calls a specified function to handle it.
ExpatÊÇÒ»¸öʼþ½âÎöÆ÷£¬Ëü½«Ò»¸öXMLÎĵµÊÓΪһϵÁеÄʼþ¡£µ±Ê¼þ·¢Éúʱ£¬Ëü½«»áÇëÇóÒ»¸öÖ¸¶¨µÄº¯ÊýÈ¥´¦ÀíËü¡£

Expat is a non-validating parser, and ignores any DTDs linked to a document. However, if the document is not well formed it will end with an error message.
Expat²»¶ÔÓÐЧÐÔ½øÐÐÑéÖ¤£¬ËüͬʱҲºöÂÔÈκÎÁ¬½Óµ½Ò»¸öÎĵµµÄDTDÁ¬½Ó¡£È»¶ø£¬Èç¹ûÎĵµµÄ¸ñʽ²»ÕýÈ·£¬Ëü½«»á³öÏÖ´íÎóÐÅÏ¢¡£

Because it is an event-based, non validating parser, Expat is fast and well suited for web applications.
ÒòΪExpat½âÎöÆ÷ÊÇ»ùÓÚʼþµÄ£¬Ëû²»¶ÔÓÐЧÐÔ½øÐÐÑéÖ¤£¬ËùÒÔËüÔËÐеÄËٶȸü¿ì£¬ÇÒÊÊÓÃÓÚÍøÂçÓ¦ÓóÌÐò¡£

The XML parser functions lets you create XML parsers and define handlers for XML events.
XML½âÎöÆ÷º¯Êý¿ÉÒÔ´´½¨XML½âÎöÆ÷²¢ÇÒ¶¨ÒåXMLʼþµÄ´¦Àí·½·¨¡£


Installation
°²×°

The XML functions are part of the PHP core. There is no installation needed to use these functions.
XMLº¯ÊýÊÇPHPºËÐijÌÐòµÄÒ»²¿·Ö£¬ËùÒÔÎÞÐè°²×°¡£


PHP XML Parser Functions
PHP XML Parserº¯Êý

PHP: indicates the earliest version of PHP that supports the function.
PHP£º×îÔçÖ§³ÖÕâЩº¯ÊýµÄPHP°æ±¾

Function
º¯Êý
Description
ÃèÊö
PHP
PHP°æ±¾
utf8_decode() Decodes an UTF-8 string to ISO-8859-1
½«Ò»¸öUTF-8×Ö·û´®½âÂë³ÉISO-8859-1
3
utf8_encode() Encodes an ISO-8859-1 string to UTF-8
°ÑISO-8859-1×Ö·û´®·­Òë³ÉUTF-8±àÂë
3
xml_error_string() Gets an error string from the XML parser
´ÓXML½âÎöÆ÷Öлñȡһ¸ö´íÎóµÄ×Ö·û´®
3
xml_get_current_byte_index() Gets the current byte index from the XML parser
´ÓXML½âÎöÆ÷ÖлñÈ¡µ±Ç°×Ö½ÚÊý
3
xml_get_current_column_number() Gets the current column number from the XML parser
´ÓXML½âÎöÆ÷ÖлñÈ¡µ±Ç°ÁÐÊý
3
xml_get_current_line_number() Gets the current line number from the XML parser
´ÓXML½âÎöÆ÷ÖлñÈ¡µ±Ç°ÐÐÊý
3
xml_get_error_code() Gets an error code from the XML parser
´ÓXML½âÎöÆ÷ÖлñÈ¡´íÎó´úÂë
3
xml_parse() Parses an XML document
¶ÔÒ»¸öXMLÎĵµ½øÐнâÎö
3
xml_parse_into_struct() Parse XML data into an array
½«XMLÊý¾Ý½âÎöµ½Ò»¸öÊý×éÖÐ
3
xml_parser_create_ns() Create an XML parser with namespace support
´´½¨Ò»¸öÖ§³ÖÃû³Æ¿Õ¼äµÄXML½âÎöÆ÷
4
xml_parser_create() Create an XML parser
´´½¨Ò»¸öXML½âÎöÆ÷
3
xml_parser_free() Free an XML parser
ÊÍ·ÅÒ»¸öXML½âÎöÆ÷
3
xml_parser_get_option() Get options from an XML parser
´ÓÒ»¸öXML½âÎöÆ÷ÖлñȡѡÏî
3
xml_parser_set_option() Set options in an XML parser
ÔÚÒ»¸öXML½âÎöÆ÷ÖÐÉèÖÃÑ¡Ïî
3
xml_set_character_data_handler() Set handler function for character data
ÉèÖô¦Àí×Ö·ûÊý¾ÝµÄº¯Êý
3
xml_set_default_handler() Set default handler function
ÉèÖÃĬÈÏ´¦ÀíµÄº¯Êý
3

xml_set_element_handler()

Set handler function for start and end element of elements
ÉèÖô¦ÀíÔªËØµÄ¿ªÊ¼ºÍ½áÊøµÄº¯Êý
3
xml_set_end_namespace_decl_handler() Set handler function for the end of namespace declarations
ÉèÖô¦ÀíÃû³Æ¿Õ¼ä[namespace]½áβµÄ´¦Àíº¯Êý
4
xml_set_external_entity_ref_handler() Set handler function for external entities
ÉèÖô¦ÀíÍⲿµÄʵÌåµÄº¯Êý
3
xml_set_notation_decl_handler() Set handler function for notation declarations
ÉèÖô¦Àí·ûºÅÉùÃ÷µÄº¯Êý
3
xml_set_object() Use XML Parser within an object
ÔÚÒ»¸ö¶ÔÏóÖÐʹÓÃXML½âÎöÆ÷
4
xml_set_processing_instruction_handler() Set handler function for processing instruction
ÉèÖÃÒ»¸öº¯Êý¶ÔÖ¸Áî½øÐд¦Àí
3
xml_set_start_namespace_decl_handler() Set handler function for the start of namespace declarations
ÉèÖô¦ÀíÃû³Æ¿Õ¼ä[namespace]ÆðʼµÄ´¦Àíº¯Êý
4
xml_set_unparsed_entity_decl_handler() Set handler function for unparsed entity declarations
ÉèÖÃδ½âÎöµÄʵÌåÉùÃ÷µÄ´¦Àíº¯Êý
3

 


PHP XML Parser Constants
PHP XML Parser³£Á¿

Constant
³£Á¿
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_MISPLACED_XML_PI (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)

ÆÀÂÛ (0) All