What is SimpleXML in PHP
In this article I am going to explain about SimpleXML in PHP.
PHP Version 5 introduce simpleXML. SimpleXML handles the most common tasks and the main benefit of using SimpleXML, you do not have to worry about encoding and poorly formatted XML.
SimpleXML converts the XML document into an object:
Elements are converted to single attributes of the SimpleXMlElement. If in the one level, there is a more than one element, they are paced inside array.
- Element data
Text data from elements are converted to string.
Example of SimpleXML
To use SimpleXML ,follow the fallowing steps:
First create an XML file:
<?xml version="1.0" encoding="ISONO"?>
<body>Don't forget me this weekend!</body>
After it, create a PHP application:
$xml = simplexml_load_file("test.xml");
echo $xml->getName() . "<br />";
foreach($xml->children() as $child)
echo $child->getName() . ": " . $child . "<br />";
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here