【www.gdgbn.com--Dom教程】

 代码如下 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;
  }
}


//本xml类代码是利用了php domdocument来解析xml文档  ?>

本文来源:http://www.gdgbn.com/wangyezhizuo/26341/