change a value xml in php but false with a node name id-7
Posted
by
Nataly Nguyen
on Stack Overflow
See other posts from Stack Overflow
or by Nataly Nguyen
Published on 2012-06-24T20:22:51Z
Indexed on
2012/06/24
21:16 UTC
Read the original article
Hit count: 234
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;
?>
© Stack Overflow or respective owner