change a value xml in php but false with a node name id-7
- by Nataly Nguyen
I want to change a xml, but fails with this code.
I think mistake with name of variable (ID-1) in php.
chang.php
<?php
include 'example.php';
$xml = new SimpleXMLElement($xmlstr);
$xml->ID-1 = '8';
$xml->name = 'Big Cliff';
$xml->asXML('test2.xml');
echo $xml->asXML();
?>
example.php
<?php
$xmlstr = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<film>
<ID-1>29</ID-1>
<name>adf</name>
</film>
XML;
?>