【发布时间】:2010-06-02 10:01:34
【问题描述】:
<testimonials>
<testimonial id="4c050652f0c3e">
<nimi>John</nimi>
<email>test@test.com</email>
<text>Some text</text>
<active>1</active>
</testimonial>
<testimonial id="4c05085e1cd4f">
<name>ats</name>
<email>some@test.ee</email>
<text>Great site!</text>
<active>0</akctive>
</testimonial>
</testimonials>
我有这个 XML 结构,我需要找到一个具有特定 id 和 change 它的 value 的推荐并保存文件。 我有一个 PHP 脚本根据其 ID 删除特定推荐:
<?php
$xmlFile = file_get_contents('test.xml');
$xml = new SimpleXMLElement($xmlFile);
$kust_id = $_GET["id"];
foreach($xml->testimonial as $story) {
if($story['id'] == $kust_id) {
$dom=dom_import_simplexml($story);
$dom->parentNode->removeChild($dom);
$xml->asXML('test.xml');
header("Location: newfile.php");
}
}
?>
【问题讨论】:
-
推荐信的价值是什么?它有4个孩子,你想改变什么?