加入收藏 | 设为首页 | 会员中心 | 我要投稿 怀化站长网 (https://www.0745zz.cn/)- 语音技术、云资源管理、物联设备、云计算、决策智能!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php dom增加xml节点函数

发布时间:2022-07-28 09:44:51 所属栏目:PHP教程 来源:互联网
导读: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. ?xml version=1.0 encoding=utf-8? !doctype message
    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.  
      
     <?xml version="1.0" encoding="utf-8"?>
  <!doctype messages [
  <!element messages (message)*>
  <!element message (name , website? , comment , date , user_ip? , user_agent? , spam)>
  ]>
  <messages>
  </messages>
    */
    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;
    }//开源代码phpfensi.com 

(编辑:怀化站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读