【发布时间】:2015-10-26 03:54:32
【问题描述】:
我有以下 XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<programmedata>
<programme id="1">
<name>Left</name>
<image_path></image_path>
<rating_point>0</rating_point>
<five_star>0</five_star>
我正在尝试使用以下代码编辑 rating_point 的值:
$xml=simplexml_load_file("content.xml");
if(!empty($_POST["rating"]) && !empty($_POST["voted_programme"])){
try{
$rating = $_POST["rating"];
$i = $_POST['voted_programme'];
$xml->programme[$i]->rating_point = $rating;
if($rating == '5')
{
$xml->programme[$i]->five_star = $rating;
}
但出现错误:Notice: Indirect modification of overloaded element of SimpleXMLElement has no effect in ...
尝试了不同的解决方案,但似乎不起作用。
【问题讨论】: