好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php读取xml文件的xml实例代码 - php类库

php读取xml文件的xml实例代码

本文章为你提供一款php xml读取类,很简单的一个xml分析类了,它可读取指它xml文档,并且输出或取得指定节点的xml数据,代码如下:

<?php  class  dom  {     protected   $_dom  = null;         public   function  __construct( $xmlfile  =  '' , $ver  =  '' , $encoding  =  '' )    {       $this  -> _dom = ( $ver  &&  $encoding )?  new  domdocument( $ver , $encoding ): new  domdocument();       $xml  = ! $xmlfile ? file_get_contents ( 'php://input' ): file_get_contents ( $xmlfile );       $this  -> _dom -> loadxml( $xml );    }         public   function  getvalue( $nodename )    {       $nodes  =  $this  -> _dom -> getelementsbytagname( $nodename );       return  null !==  $nodes  -> item(0)? $nodes  -> item(0) -> nodevalue:false;    }  }  //开源代码phpfensi测试数据     //本xml类代码是利用了php domdocument来解析xml文档     ?> 

查看更多关于php读取xml文件的xml实例代码 - php类库的详细内容...

  阅读:44次