PHP XMLLesson 74Free preview
PHP XML Expat Parser
This lesson is part of PHP · All levels
Summary
Expat-based XML Parser works event-driven: you register the handler function, and the parser calls it whenever it encounters an open tag, a closed tag, or text data. Parser is created with xml_parser_create() and must be returned with xml_parser_free(). This approach is efficient for large documents because it doesn't build a full tree in memory.
Key points
- Parser is created with xml_parser_create() and then removed with xml_parser_free().
- Handles the opening and closing events.
- Xml_set_character_data_handler() deals with text between tags.
- Xml_parse() processes the data snippet and returns the parsing success results.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.