2016-11-24, 02:16:07
(2016-11-24, 01:01:02)shawn_a Wrote: does your input data change also
"$atts= $data->children();" instead of attributes , is that correct for the input data ?
It looks ok at a glance, hmm
also you are modifying your foreach value variable $data
$data = $xml->addChild('data');
use another varname like $node
PHP Code:foreach ($testfile->data as $data)
{
$atts= $data->children();
$node= $xml->addChild('data');
$node->addChild('name', $atts['name']);
}
Thank shawn_a for your reply.
After your suggestion looks like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<test><data><name/></data><data><name>6</name></data></test>
previous entries are empty only displays the last!?