一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

php dom增加xml节点函数

时间:2010-08-27 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码
    function: addcomment
   
    adds a comment.
   
    parameters:
      $data - associative array of data, must contain 'name', 'website', 'comment', 'date', 'user_ip', 'user_agent', and 'spam'.
     
    returns:
      id of the new comment.
  
  


]>


  */
  public function addcomment($data) {
    $xml = new simplexmlelement($this->getcontents(true));
    $message = $xml->addchild('message');
    $id = $this->generateid();
    $message->addattribute('mid', $id);
    foreach ($data as $key => $value) {
      $message->addchild($key, htmlspecialchars($value, ent_quotes));
    }
    $this->putcontents($xml->asxml());
   
    return $id;
  }

热门栏目