addChild('note');
$newNote->addChild('title', $title);
$newNote->addChild('content', $content);
// 保存XML文件
$xml->asXML($xmlFilePath);
}
// 删除记事本记录
if (isset($_GET['delete'])) {
$noteId = $_GET['delete'];
// 在XML文件中删除指定记事本记录
foreach ($xml->xpath("//note[@id='$noteId']") as $note) {
$noteParent = $note->xpath('..');
unset($noteParent[0][$note->getName()]);
}
// 保存XML文件
$xml->asXML($xmlFilePath);
}
/*if (isset($_GET['delete'])) {
$noteId = $_GET['delete'];
$notes = $xml->xpath("//note[@id='$noteId']");
if (isset($notes[0])) {
unset($notes[0]);
}
$xml->asXML($xmlFilePath);
}
*/
// 更新记事本记录
if (isset($_POST['update'])) {
$noteId = $_POST['id'];
$title = $_POST['title'];
$content = $_POST['content'];
// 在XML文件中更新指定记事本记录
foreach ($xml->xpath("//note[@id='$noteId']") as $note) {
$note->title = $title;
$note->content = $content;
}
// 保存XML文件
$xml->asXML($xmlFilePath);
}
// 查询记事本记录
$notes = $xml->xpath("//note");
?>
网络记事本
网络记事本
萌新一枚。想用XML弄个一简单的记事本功能,找了一个代码。运行完之后可以添加,不过不能删除呢。请老师帮我一下。谢谢~
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号