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


PHP phpQuery::DOMNodeListToArray方法代码示例

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


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

示例1: markup

 /**
  * Return document markup, starting with optional $nodes as root.
  *
  * @param $nodes	DOMNode|DOMNodeList
  * @return string
  */
 public function markup($nodes = null, $innerMarkup = false)
 {
     if (isset($nodes) && count($nodes) == 1 && $nodes[0] instanceof DOMDOCUMENT) {
         $nodes = null;
     }
     if (isset($nodes)) {
         $markup = '';
         if (!is_array($nodes) && !$nodes instanceof DOMNODELIST) {
             $nodes = array($nodes);
         }
         if ($this->isDocumentFragment && !$innerMarkup) {
             foreach ($nodes as $i => $node) {
                 if ($node->isSameNode($this->root)) {
                     //	var_dump($node);
                     $nodes = array_slice($nodes, 0, $i) + phpQuery::DOMNodeListToArray($node->childNodes) + array_slice($nodes, $i + 1);
                 }
             }
         }
         if ($this->isXML && !$innerMarkup) {
             self::debug("Getting outerXML with charset '{$this->charset}'");
             // we need outerXML, so we can benefit from
             // $node param support in saveXML()
             foreach ($nodes as $node) {
                 $markup .= $this->document->saveXML($node);
             }
         } else {
             $loop = array();
             if ($innerMarkup) {
                 foreach ($nodes as $node) {
                     if ($node->childNodes) {
                         foreach ($node->childNodes as $child) {
                             $loop[] = $child;
                         }
                     } else {
                         $loop[] = $node;
                     }
                 }
             } else {
                 $loop = $nodes;
             }
             self::debug("Getting markup, moving selected nodes (" . count($loop) . ") to new DocumentFragment");
             $fake = $this->documentFragmentCreate($loop);
             $markup = $this->documentFragmentToMarkup($fake);
         }
         if ($this->isXHTML) {
             self::debug("Fixing XHTML");
             $markup = self::markupFixXHTML($markup);
         }
         self::debug("Markup: " . substr($markup, 0, 250));
         return $markup;
     } else {
         if ($this->isDocumentFragment) {
             // documentFragment, html only...
             self::debug("Getting markup, DocumentFragment detected");
             //				return $this->markup(
             ////					$this->document->getElementsByTagName('body')->item(0)
             //					$this->document->root, true
             //				);
             $markup = $this->documentFragmentToMarkup($this);
             // no need for markupFixXHTML, as it's done thought markup($nodes) method
             return $markup;
         } else {
             self::debug("Getting markup (" . ($this->isXML ? 'XML' : 'HTML') . "), final with charset '{$this->charset}'");
             $markup = $this->isXML ? $this->document->saveXML() : $this->document->saveHTML();
             if ($this->isXHTML) {
                 self::debug("Fixing XHTML");
                 $markup = self::markupFixXHTML($markup);
             }
             self::debug("Markup: " . substr($markup, 0, 250));
             return $markup;
         }
     }
 }
开发者ID:Orchild,项目名称:mt,代码行数:79,代码来源:DOMDocumentWrapper.php


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