當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。