6th May 2010 - 12 minutes read time
XML data extraction can be a common task, but to work directly with this data you need to understand how PHP parses XML. There are various different functions involved in parsing XML in PHP, all of which work together to extract data from a XML document. I will go through each of these functions and tie them together at the end.
xml_parser_create()
This function is used to create the parser object that will be used by the rest of the process. This object is used to store data and configuration options and is passed to each of the functions involved.
$xml_parser = xml_parser_create();
xml_set_element_handler()
Next we need to set up the functions that will be used in the parsing of the script. The xml_set_handler() method takes the following parameters: