note 89644 modified in function.simplexml-element-addChild by thiago
| From: | thiago@php.net | Date: | Tue, 17 Mar 2009 18:20:32 +0000 |
| Subject: | note 89644 modified in function.simplexml-element-addChild by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-152061@lists.php.net to get a copy of this message | ||
Simple way to add a text node:
<?php
$x=simplexml_load_string('<test />');
$x->addAttribute('id','x01');
$x[0]='text node';
echo $x->asXML();
?>
Result:
<?xml version="1.0"?>
<test id="x01">text node</test>
Any numeric array subscript (in this case 0) will work.
--was--
Simple way to add a text node:
$x=simplexml_load_string('<test />');
$x->addAttribute('id','x01');
$x[0]='text node';
echo $x->asXML();
Result:
<?xml version="1.0"?>
<test id="x01">text node</test>
Any numeric array subscript (in this case 0) will work.
http://php.net/manual/en/function.simplexml-element-addChild.php