PHP with XML

SimpleXML is a tree-based parser. SimpleXML provides an easy way of getting an element’s name, attributes and textual content if you know the XML document’s structure or layout. 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, SimpleXML takes a fewer lines of code to read text data from an element.


$myXML =
"<?xml version='1.0' encoding='UTF-8'?>
<note>
<to>To</to>
<from>MFAZIZ</from>
<heading>Reminder</heading>
<body>Don't leave me!</body>
</note>";

$xml=simplexml_load_string($myXMLData) or die("Error: Cannot create object");
print_r($xml);

Leave a Reply

Your email address will not be published. Required fields are marked *