xml中的标记值保持不变(php + xml)

时间:2017-01-29 14:07:40

标签: php xml

我正在尝试更改标记值,但它不成功。这是我的xml格式和php代码,当我使用$ polls-> poll [0] - > person [0] ="更改"时,它工作正常......:



$fname = getPollFile();
$polls = simplexml_load_file($fname);

foreach ($polls->poll as $poll){   
  foreach($poll->person as $person){
    $person = "process";
   }
}
   
$polls->asXML($fname);

<?xml version="1.0" encoding="UTF-8"?>
<polls>
   <poll title="Ccccc">
      <person id="111">active</person>
      <person id="222">active</person>
   </poll>
</polls>
&#13;
&#13;
&#13;

0 个答案:

没有答案