Working with an xml parser for PHP The steps involved in working with a parser are to create the parser first, and then set the handlers for the tags and the character data in the XML file. Then the XML file is opened, read, and parsed using the parser and then the memory taken up by the parser is freed. The XML file is then closed. Functions to handle the tags - starting and ending - are created. A function to handle the character data is also created. After this the parser is created using the command like 'xml_parser_create();'. 'xml_set_element_handler();' and 'xml_set_character_data_handler();' are used to handle the tags and the character data found in the XML file. The XML parser is passed as the first argument to these functions. Parsing of the XML data can be done by using an 'if' condition so that if parsing fails you can print out an error. Error printing can be done along with the line number in which parsing failed so that you can debug them easily.
|
|
||
|
|||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2019 - All Rights Reserved.