php言語 addChild()関数

1.説明
class SimpleXMLElement
{
string addChild(name,value,ns)
}
2.xmlファイル
<?xml version="1.0″ encoding="ISO-8859-1″?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don’t forget the meeting!</body>
</note>

3.phpコード
<?php
$xml = simplexml_load_file(“test.xml");

$xml->body[0]->addChild(“date", “214-08-08");

foreach ($xml->body->children() as $child)
{
echo “Child node: " . $child;
}
?>

4.結果輸出:
Child node: 2014-08-08

Source

Posted by arkgame