Revision: 37164
Updated Code
at December 5, 2010 06:45 by hejaaa
Updated Code
<?php
header('Content-type: text/xml');
// first <winner id="1" /> node
$xml =
'<win visit="0">
<winner id="1" />
</win>';
$xml = simplexml_load_string($xml);
// second node
$newNode = $xml->addChild("winner");
$newNode->addAttribute("id","2");
// three node
$newNode = $xml->addChild("winner");
$newNode->addAttribute("id","3");
echo $xml->asXML();
?>
// RESULT
<win visit="0">
<winner id="1"/>
<winner id="2"/>
<winner id="3"/>
</win>
Revision: 37163
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 5, 2010 06:33 by hejaaa
Initial Code
<?php
header('Content-type: text/xml');
// first <winner id="1" /> node
$xml =
'<win visit="0">
<winner id="1" />
</win>';
$xml = simplexml_load_string($xml);
// second node
$newNode = $xml->addChild("winner");
$newNode->addAttribute("id","2");
// three node
$newNode = $xml->addChild("winner");
$newNode->addAttribute("id","3");
echo $xml->asXML();
?>
Initial URL
Initial Description
Initial Title
addChild and attribute with simpleXml
Initial Tags
xml
Initial Language
PHP