当前位置: 首页>>代码示例>>PHP>>正文


PHP XML::_XPT方法代码示例

本文整理汇总了PHP中XML::_XPT方法的典型用法代码示例。如果您正苦于以下问题:PHP XML::_XPT方法的具体用法?PHP XML::_XPT怎么用?PHP XML::_XPT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML的用法示例。


在下文中一共展示了XML::_XPT方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _domxpath

 /**
  *  INSTANTIATE DOMDocument
  *  create or set a new Domdocument based upon a string or an already declared object
  **/
 private static function _domxpath($path = false, $obj = false, $force = false, $create = false)
 {
     self::$_LDD = false;
     // check that DomDocument and DomXPath are available
     // we don't need to send an error since the Core::library will handle that.
     if (!class_exists('DomDocument') || !class_exists('DOMXPath')) {
         die;
     }
     // return if $_DOM is already declared and we're not forcing re-instantiation.
     if (self::$_DOM instanceof DomDocument && !$force) {
         return self::$_DOM;
     }
     // if no object is specified, instantiate a new one.
     if (!$obj) {
         self::$_DOM = new DomDocument(self::$_VER, self::$_CHR);
         self::$_DOM->preserveWhiteSpace = self::$_PWS;
         self::$_DOM->formatOutput = self::$_FOU;
         // if object provided is a valid instance, use it instead.
     } elseif ($obj instanceof DomDocument) {
         self::$_DOM = $obj;
         // we override force, so xpath will be reinstantiated again.
         $force = true;
         // if object isn't dom... show error.
     } else {
         Core::error('VARTYP', 'LIBTIT', array(__CLASS__, 'object', 'DomDocument'));
     }
     // if there's a path set it and load it.
     if ($path) {
         // we make sure the path is set correctly
         $path = self::path($path, $create, 3);
         //  if the specified file doesn't exist, or the file exists
         //  but it doesn't have a root element defined AND the function
         //  needs a file to be created, do so.
         if ($create && (!file_exists($path) || !self::$_DOM->documentElement)) {
             self::$_DOM->appendChild(self::$_DOM->createElement('root'));
             self::save(false, false);
             self::$_LDD = true;
             //  if we're not creating but the file already exists and has content on it, load it.
         } elseif (!$create && file_exists($path) && filesize($path) > 0) {
             self::$_DOM->load($path);
             self::$_LDD = true;
         }
     }
     // instantiate the domxpath object
     if (!self::$_XPT instanceof DOMXPath || $force) {
         self::$_XPT = new DOMXPath(self::$_DOM);
     }
     return self::$_DOM;
 }
开发者ID:hectormenendez,项目名称:h23,代码行数:53,代码来源:xml.php


注:本文中的XML::_XPT方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。