當前位置: 首頁>>代碼示例>>PHP>>正文


PHP phpQuery::importMarkup方法代碼示例

本文整理匯總了PHP中phpQuery::importMarkup方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpQuery::importMarkup方法的具體用法?PHP phpQuery::importMarkup怎麽用?PHP phpQuery::importMarkup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在phpQuery的用法示例。


在下文中一共展示了phpQuery::importMarkup方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: pq

 /**
  * Enter description here...
  *
  * @return false|phpQuery|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
  */
 public static function pq($arg1, $context = null)
 {
     // TODO support DOMNodes as $context, find out ownerDocument, search loaded DOMs
     if (!$context) {
         $domId = self::$lastDomId;
     } else {
         if ($context instanceof self) {
             $domId = $context->domId;
         } else {
             if ($context instanceof DOMDOCUMENT) {
                 foreach (phpQuery::$documents as $id => $document) {
                     if ($context->isSameNode($document['document'])) {
                         $domId = $id;
                     }
                 }
                 if (!$domId) {
                     throw new Exception('Orphaned DOMNode');
                     //				$domId = self::newDocument($context);
                 }
             } else {
                 if ($context instanceof DOMNODE) {
                     foreach (phpQuery::$documents as $id => $document) {
                         if ($context->ownerDocument->isSameNode($document['document'])) {
                             $domId = $id;
                         }
                     }
                     if (!$domId) {
                         throw new Exception('Orphaned DOMNode');
                         //				$domId = self::newDocument($context->ownerDocument);
                     }
                 } else {
                     $domId = $context;
                 }
             }
         }
     }
     if ($arg1 instanceof self) {
         /**
          * Return $arg1 or import $arg1 stack if document differs:
          * pq(pq('<div/>'))
          */
         if ($arg1->domId == $domId) {
             return $arg1;
         }
         $phpQuery = new phpQuery($domId);
         $phpQuery->elements = array();
         foreach ($arg1->elements as $node) {
             $phpQuery->elements[] = $phpQuery->DOM->importNode($node, true);
         }
         return $phpQuery;
     } else {
         if ($arg1 instanceof DOMNODE || is_array($arg1) && isset($arg1[0]) && $arg[0] instanceof DOMNODE) {
             /**
              * Wrap DOM nodes with phpQuery object, import into document when needed:
              * pq(array($domNode1, $domNode2))
              */
             $phpQuery = new phpQuery($domId);
             if (!$arg1 instanceof DOMNODELIST && !is_array($arg1)) {
                 $arg1 = array($arg1);
             }
             $phpQuery->elements = array();
             foreach ($arg1 as $node) {
                 $phpQuery->elements[] = !$node->ownerDocument->isSameNode($phpQuery->DOM) ? $phpQuery->DOM->importNode($node, true) : $node;
             }
             return $phpQuery;
         } else {
             if (self::isMarkup($arg1)) {
                 /**
                  * Import HTML:
                  * pq('<div/>')
                  */
                 $phpQuery = new phpQuery($domId);
                 $phpQuery->importMarkup($arg1);
                 return $phpQuery;
             } else {
                 /**
                  * Run CSS query:
                  * pq('div.myClass')
                  */
                 $phpQuery = new phpQuery($domId);
                 if ($context && $context instanceof self) {
                     $phpQuery->elements = $context->elements;
                 } else {
                     if ($context && $context instanceof DOMNODELIST) {
                         $phpQuery->elements = array();
                         foreach ($context as $node) {
                             $phpQuery->elements[] = $node;
                         }
                     } else {
                         if ($context && $context instanceof DOMNODE) {
                             $phpQuery->elements = array(DOMNODE);
                         }
                     }
                 }
                 return $phpQuery->find($arg1);
//.........這裏部分代碼省略.........
開發者ID:a2aitalk,項目名稱:seo-automatic-seo-tools,代碼行數:101,代碼來源:phpQuery.php


注:本文中的phpQuery::importMarkup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。