simple对xml文档的操作

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<?php
$xml_cont=file_get_contents("mysql.xml");
$sxe=new SimpleXMLElement($xml_cont);
/*var_dump($sxe);
echo "<br>";
for($i=0;$i<=3;$i++){
echo $sxe->book[$i]->title[0];
echo $sxe->book[$i]->author[0];
echo "<br>";
}
$new_book=$sxe->addChild('book');
$new_book->addAttribute('title','侠客行0p');
$sxe->asXML('mysql_xml.xml');
unset($sxe->book[0]);
$sxe->asXML('mysql.xml');*/
$sxe->book[1]->author='aaaaa';
$sxe->asXML('mysql.xml');
?>
</body>
</html>

你可能感兴趣的:(JavaScript)