Using PHP's SimpleXML extension that was introduced back in PHP As you might expect, the former will load the XML file a file and the DOM tree into memory and returns a SimpleXMLElement object representation of it. Convert a well-formed XML string into a SimpleXMLElement object, then output keys and elements of the object: php $note=XML Tove. Convert an XML file into a SimpleXMLElement object, then output keys and elements of the object: php $xml=simplexml_load_file("houdini-connections.co.uk"); print_r($xml );?>. Parameters ¶. data. A well-formed XML string. class_name. You may use this optional parameter so that simplexml_load_string() will return an object of the. SimpleXML turns an XML document into a data structure you can iterate through like a collection of arrays and objects. Compared to DOM or the Expat parser. Parameters ¶. filename. Path to the XML file. Note: Libxml 2 unescapes the URI, so if you want to pass e.g. b&c as the URI parameter a, you have to call. How To Read XML file contnet in PHP using SimpleXML php extension. Reading XML file content in PHP script and convert them to object with SimpleXML. Let's say you have an XML file (like the one that follows) that you want to turn into an associative array in PHP. Doing this takes a few steps but. Get the node values from the "houdini-connections.co.uk" file: Example. php $xml= simplexml_load_file("houdini-connections.co.uk") or die("Error: Cannot create object"); echo $xml-> to. " ";. simplexml loads xml into an object and you'll be able to work with it exactly as you're asking. $xml = simplexml_load_string($stories);.