addChild()

It adds a child element the SimpleXML element

Example

<?php
$xml = simplexml_load_file(“test.xml”);
$xml->server[0]->addChild(“version”, “5”);
foreach ($xml->server->children() as $child)
{
echo $child . “<br />”;
}
?>

Output

5

XML

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<web>
<server>Apache</server>
<lan>PHP</lan>
<client>Javascript</client>
</web>

Share