519daddxml.php<?
class myXML extends DomDocument
{
private $root;
public function __construct()
{ parent::__construct();
///*
if(!file_exists('date.xml'))
{
$xmldata = '<?xml version="1.0" encoding="utf-8"?><table></table>';
$this->loadXML($xmldata);
$this->save('date.xml');
}
else
{
$this->load('date.xml');
}
//*/
}
public function addData($areaid, $qq, $zone, $sex, $old, $face, $descript)
{
$this->root = $this->documentElement;
$this->formatOutput = true; //define child
$uid = $this->createAttribute ('uid');
$text = $this->createTextNode('q'.$qq);
$uid ->appendChild($text); $areaidNode = $this->createElement('areaid');
$text = $this->createTextNode($areaid);
$areaidNode -> appendChild($text); $qqNode = $this->createElement('qq');
$text = $this->createTextNode($qq);
$qqNode -> appendChild($text); $zoneNode = $this->createElement('zone');
$text = $this->createTextNode($zone);
$zoneNode -> appendChild($text); $sexNode = $this->createElement('sex');
$text = $this->createTextNode($sex);
$sexNode -> appendChild($text); $oldNode = $this->createElement('old');
$text = $this->createTextNode($old);
$oldNode -> appendChild($text); $faceNode = $this->createElement('face');
$text = $this->createTextNode($face);
$faceNode -> appendChild($text); $descriptNode= $this->createElement('descript');
$text = $this->createTextNode($descript);
$descriptNode-> appendChild($text); $addtimeNode= $this->createElement('addtime');
$text = $this->createTextNode(date('Y-m-d'));
$addtimeNode-> appendChild($text);
//end define child //append attribute or element
$nodeUser = $this->createElement('user');
$nodeUser->appendChild($uid);
$nodeUser->appendChild($areaidNode);
$nodeUser->appendChild($qqNode);
$nodeUser->appendChild($zoneNode);
$nodeUser->appendChild($sexNode);
$nodeUser->appendChild($oldNode);
$nodeUser->appendChild($faceNode);
$nodeUser->appendChild($descriptNode);
$nodeUser->appendChild($addtimeNode);
//end append attribute or element $this->root->appendChild($nodeUser);
$this->save('date.xml');
// header('location:index.php');
die();
}
}
//if(strtolower($_SERVER['REQUEST_METHOD'])=='post')
//{
// extract($_POST, EXTR_OVERWRITE);
$dom = new myXML;
$dom->addData('32e', '49220977', 'fsdfdsf', '男', '23', 'bai', '1231232');//}
?>
出错提示:Warning: DOMDocument::load() [domdocument.load]: Input is not proper UTF-8, indicate encoding ! Bytes: 0xE5 0x8C 0x3F 0x32 in file:///D:/AppServ/www/soupiao/manages/date.xml, line: 13 in D:\AppServ\www\soupiao\manages\519daddxml.php on line 18Fatal error: Call to a member function appendChild() on a non-object in D:\AppServ\www\soupiao\manages\519daddxml.php on line 78请高手看看啊,到底是怎么回事?怎么一会可以一会就不可以,就出错?
class myXML extends DomDocument
{
private $root;
public function __construct()
{ parent::__construct();
///*
if(!file_exists('date.xml'))
{
$xmldata = '<?xml version="1.0" encoding="utf-8"?><table></table>';
$this->loadXML($xmldata);
$this->save('date.xml');
}
else
{
$this->load('date.xml');
}
//*/
}
public function addData($areaid, $qq, $zone, $sex, $old, $face, $descript)
{
$this->root = $this->documentElement;
$this->formatOutput = true; //define child
$uid = $this->createAttribute ('uid');
$text = $this->createTextNode('q'.$qq);
$uid ->appendChild($text); $areaidNode = $this->createElement('areaid');
$text = $this->createTextNode($areaid);
$areaidNode -> appendChild($text); $qqNode = $this->createElement('qq');
$text = $this->createTextNode($qq);
$qqNode -> appendChild($text); $zoneNode = $this->createElement('zone');
$text = $this->createTextNode($zone);
$zoneNode -> appendChild($text); $sexNode = $this->createElement('sex');
$text = $this->createTextNode($sex);
$sexNode -> appendChild($text); $oldNode = $this->createElement('old');
$text = $this->createTextNode($old);
$oldNode -> appendChild($text); $faceNode = $this->createElement('face');
$text = $this->createTextNode($face);
$faceNode -> appendChild($text); $descriptNode= $this->createElement('descript');
$text = $this->createTextNode($descript);
$descriptNode-> appendChild($text); $addtimeNode= $this->createElement('addtime');
$text = $this->createTextNode(date('Y-m-d'));
$addtimeNode-> appendChild($text);
//end define child //append attribute or element
$nodeUser = $this->createElement('user');
$nodeUser->appendChild($uid);
$nodeUser->appendChild($areaidNode);
$nodeUser->appendChild($qqNode);
$nodeUser->appendChild($zoneNode);
$nodeUser->appendChild($sexNode);
$nodeUser->appendChild($oldNode);
$nodeUser->appendChild($faceNode);
$nodeUser->appendChild($descriptNode);
$nodeUser->appendChild($addtimeNode);
//end append attribute or element $this->root->appendChild($nodeUser);
$this->save('date.xml');
// header('location:index.php');
die();
}
}
//if(strtolower($_SERVER['REQUEST_METHOD'])=='post')
//{
// extract($_POST, EXTR_OVERWRITE);
$dom = new myXML;
$dom->addData('32e', '49220977', 'fsdfdsf', '男', '23', 'bai', '1231232');//}
?>
出错提示:Warning: DOMDocument::load() [domdocument.load]: Input is not proper UTF-8, indicate encoding ! Bytes: 0xE5 0x8C 0x3F 0x32 in file:///D:/AppServ/www/soupiao/manages/date.xml, line: 13 in D:\AppServ\www\soupiao\manages\519daddxml.php on line 18Fatal error: Call to a member function appendChild() on a non-object in D:\AppServ\www\soupiao\manages\519daddxml.php on line 78请高手看看啊,到底是怎么回事?怎么一会可以一会就不可以,就出错?
解决方案 »
- 关于xampp1.77 windows 版本 apache busy的问题
- php中$_SERVER[PHP_SELF] 和 $_SERVER[SCRIPT_NAME]之间的区别
- 全部分数跪求:Koobi CMS安装后找不到tpl文件,和出现空白页面
- 怎么对二维数组进行排序,在线等
- 关于include “/ 问题,求助~~~
- 求救!!!!
- 急:怎么在php中加载dbase函数库?
- 请问大侠们,在搜索的时候需要用到那些函数?
- 急用,希望大虾不吝赐教。我只能给这么多分,如解决问题,我会再开帖子答谢的。
- 模拟php https cookies 访问
- 请教大家关于mysql的order By Rand()问题
- NetBeans6.9有没有支持SMARTY的编辑插件啊
<?xml version="1.0" encoding="utf-8"?>
指定的与对应的中文编码不一致.如果你指定为utf-8,要将date.xml保存成utf-8格式的.