group-icon
PHP Programming
Group for all things PHP, Coding Help, Problems and Solutions
101 Members
Join this group to post and comment.
DHIRAJ LOTLIKAR
DHIRAJ LOTLIKAR
Information Technology
05 Feb 2019

What is SAX and DOM parser in PHP?

SAX parser has used to parse the xml file and better for memory management than sample xml parser and DOM. It does not keep any data in memory so it can be used for very large files. SAX is an approach to parse XML documents, but not to validate them. The good thing is that you can use it with both PHP 4 and PHP 5 with no changes. You create a SAX (Simple API for XML) parser using xml_parser_create(). This parser can look at an XML file and react upon various events.

The following three events are the most important ones:

1) Beginning of an element

2) End of an element

3) CDATA blocks

A HTML Dom parser written in PHP5.X versions. Dom Parser is very good at dealing with XML as well as HTML. Dom parser travels based on tree based and before access the data, it will load the data into dom object and it will update the data to the web browser. The DOM parser is a tree-based parser. The DOM parser functions are part of the PHP core. There is no installation needed to use these functions.


Shruthi Pillai
Shruthi Pillai
Information Technology
1mo ago

SAX parser has used to parse the xml file and better for memory management than sample xml parser and DOM. It does not keep any data in memory so it can be used for very large files.  

A HTML Dom parser written in PHP5.X versions. Dom Parser is very good at dealing with XML as well as HTML. Dom parser travels based on tree based and before access the data, it will load the data into dom object and it will update the data to the web browser.