用户操作
[即时聊天] [发私信] [加为好友]
徐兴ID:striker_un
2488次访问,排名2万外好友7人,关注者11
striker_un的文章
原创 8 篇
翻译 0 篇
转载 1 篇
评论 2 篇
最近评论
striker_un:常用查询字符串处理
function chk_query($word) {
global $skip_ary,$split_ary,$trans_ary;
$res = urldecode($word);
$res .= ' '.strtoupper($res);
$res = strtr($res,$split_ary);
DOLOY:16 yellow card ,4 red
文章分类
收藏
    相册
    徐兴
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 简单的xml处理类.收藏

     | 旧一篇: 批量 gb->utf-8编码转换. (转)

    <?php
    header('content-type: text/html; charset=utf-8');
    class OpXML
    {
       
    private $fpath;
       
    private $enter;
       
    private $root;

       
    function __construct($root,$fpath)
        {
           
    $this->fpath=$fpath;
           
    $this->root=$root;
           
    $this->enter=chr(13).chr(10);
           
    $this->checkFile();
        }

       
    /*
        *函数名:insert
        *说明:插入一条记录
       
    */
       
    public function insert($fields)
        {
           
    $content=$this->getFileContent();
                   
           
    $record='<partners>'.$this->enter;
           
    foreach($fields as $k=>$v)
            {
               
    $record.="<$k name=$v></$k>".$this->enter;
            }
           
    $record.='</partners>'.$this->enter.$this->enter;
           
    $this->save(preg_replace('/(?=<\/'.$this->root.'>)/',$record,$content));
           
    return true;
        }
       
    private function checkFile()
        {
           
    if(!file_exists($this->fpath))
            {
               
    $xmlstr='';
               
    $xmlstr='<?xml version="1.0" encoding="UTF-8"?>'.$this->enter;
               
    $xmlstr.='<'.$this->root.'>'.$this->enter.$this->enter;
               
    $xmlstr.='</'.$this->root.'>';
               
    $this->save($xmlstr);
            }
       
        }
       
    private function getFileContent()
        {
           
    $hd=fopen($this->fpath,'r');
           
    $content=fread($hd,filesize($this->fpath));
           
    fclose($hd);
           
    return $content;
        }

       
    private function save($content)
        {
           
    $hd=fopen($this->fpath,'w');
           
    fwrite($hd,$content);
           
    fclose($hd);
        }
    }

    $rootname='person';//根标签名
    $fpath='./12.xml';//文件的路径,不用手动创建文件
    $x=new OpXML('person',$fpath);
    $name = $_post['children'];
    if(!isset($name))$name="yuan";
    //从form增加一条记录
    $arr=array('partner'=>$name);
    $x->insert($arr);

    ?>

    发表于 @ 2008年04月02日 22:04:00|评论(loading...)|编辑

     | 旧一篇: 批量 gb->utf-8编码转换. (转)

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © striker_un