The SimpleXML extension, enabled by default in PHP 5, is the easiest way to work with XML. You don't need to remember a difficult DOM API. You just access the XML through a data structure representation. Here are its four simple rules:
Properties denote element iterators.
Numeric indices denote elements.
Non-numeric indices denote attributes.
String conversion allows access to TEXT data.
By using these four rules, you can access all the data from an XML file.
You can create a SimpleXML object in any of three ways, as shown in this example:
<?php $sx1 = simplexml_load_file('example.xml'); $string = <<<XML <?xml version='1.0'?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> ...