所以这是我的问题!我在我的网站中使用 simplexml 作为 MySQL 的替代品,因为我使用的是移动设备,它与 addChild 请求一起工作正常,但是当它提交时,它要么覆盖原始 xml 文件,要么用代码 xml 文件解释它:
<?xml version="1.0"?>
<video><title>title 22</title></video>
php文件:
<?php
$file = 'database.xml';
$title = $_POST['1'];
$xml = simplexml_load_file($file);
$xmlne = $xml->videos;
$d = "<video></video>";
$newvid = new SimpleXMLElement($d);
$newvid->addChild('title' , $title);
$newvid->asXML($file);
?>
<form action="index.php" method="post">
<input type="text" value="title" name="1">
<input type="submit" value="post"/>
</form>