1个回答
展开全部
class Articles extends DomDocument {
function __construct() {
//必须调用!
parent::__construct();
}
function addArticle($title) {
$item = $this->createElement("item");
$titlespace = $this->createElement("title");
$titletext = $this->createTextNode($title);
$titlespace->appendChild($titletext);
$item->appendChild($titlespace);
$this->documentElement->appendChild($item);
}
}
$dom = new Articles();
$dom->load("articles.xml");
$dom->addArticle("XML in PHP5");
print $dom->save("newfile.xml");
HTML
本文来自: 脚本之家(www.jb51.net) 详细出处参考:http://www.jb51.net/article/1474.htm
function __construct() {
//必须调用!
parent::__construct();
}
function addArticle($title) {
$item = $this->createElement("item");
$titlespace = $this->createElement("title");
$titletext = $this->createTextNode($title);
$titlespace->appendChild($titletext);
$item->appendChild($titlespace);
$this->documentElement->appendChild($item);
}
}
$dom = new Articles();
$dom->load("articles.xml");
$dom->addArticle("XML in PHP5");
print $dom->save("newfile.xml");
HTML
本文来自: 脚本之家(www.jb51.net) 详细出处参考:http://www.jb51.net/article/1474.htm
参考资料: http://www.jb51.net/article/1474.htm
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询