这是网站主页,简单优化了一下,不过还是巨丑务必,见谅见谅,用到了PHP的simple_php插件,很简单,但是功能也有限,但是对于我们使用来说已经足够了。
<!DOCTYPE html>
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0-rc1.js"></script>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<div text-align="center"><h3 >xml实验课作业:增删改查</h3></div>
<br>
<form role="form" action="change.php" method="post">
<div class="form-group">
<div class="form-inline"><label for="name">标签:</label><input class="form-control" placeholder="请输入" type="text" name="id"></div>
<div class="form-inline"><label for="name">属性:</label><input class="form-control" placeholder="请输入" type="text" name="value"></div>
<button class="btn btn-success" type="submit" >提交</button>
</div>
</form>
<form action="delete.php" method="post">
<div class="form-inline"><label for="name">删除标签:</label><input placeholder="请输入" class="form-control" type="text" name="id"></div>
<button type="submit" class="btn btn-success">提交</button>
</form>
<br>
<div>所有信息:</div>
<?php
$xml=simplexml_load_file("note.xml");
echo $xml->getName() . "<br>";
foreach($xml->children() as $child)
{
if($child!=''){
echo " ".$child->getName() . ": " . $child . "<br>";
}
}
?>
</body>
</html>
下面代码是change.php,主要是将提交的增加或者修改命令进行执行
<!DOCTYPE html>
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0-rc1.js"></script>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<?php
$xml=simplexml_load_file("note.xml");
$id=$_POST["id"];
$value=$_POST["value"];
//$xml->from=$from;直接修改方式
if($id!=''){
$xml->$id=$value;
}
$xml->asXML('note.xml');
echo "修改完毕,请返回";
?>
<br>
<a href="http://123.206.58.204"> 返回</a>
<br>
<?php
$xml=simplexml_load_file("note.xml");
foreach($xml->children() as $child)
{
if($child!=''){
echo $child->getName() . ": " . $child . "<br>";
}
}
?>
<br>
</html>
这个是delete.php,对标签进行删除
<!DOCTYPE html>
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0-rc1.js"></script>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<?php
$xml=simplexml_load_file("note.xml");
$id=$_POST["id"];
//$xml->from=$from;直接修改方式
$xml->$id=$value;
$xml->asXML('note.xml');
echo "修改完毕,请返回";
?>
<br>
<a href="http://123.206.58.204">返回</a>
<br>
<?php
$xml=simplexml_load_file("note.xml");
echo $xml->getName() . "<br>";
foreach($xml->children() as $child)
{
if($child!=''){
echo $child->getName() . ": " . $child . "<br>";
}
}
?>
</body>
</html>
主要页面