SimpleXML is a PHP extension introduced with PHP 5. It allows users to easily handle XML data in PHP. SimpleXML converts any XML data to an object which can be easily processed with normal property selectors and array iterators. You must have installed php-simplexml extension on your system to use examples of this tutorial. A Sample XML File Here is a sample XML file used for this tutorial. The XML filename is employees.xml which you will see in further examples of this tutorial.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?xml version="1.0"?> <company> <employee> <firstname>Tom</firstname> <lastname>Cruise</lastname> <designation>MD</designation> <salary>500000</salary> </employee> <employee> <firstname>Tyler</firstname> <lastname>Horne</lastname> <designation>CEO</designation> <salary>250000</salary> </employee> </company> |
Read Specific XML Elements Use simplexml_load_file function to load external XML file in your PHP program…

