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


PHP domDocument::importNode方法代码示例

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


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

示例1: frameResponse

 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $mplme = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $frameResponseObject->setTitle("Mplme");
     if (isset($_REQUEST["xmlData"])) {
         $xmlDoc = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $mplme->get_path() . "/data.xml");
         if ($xmlDoc === 0 || !$xmlDoc instanceof \steam_document) {
             $xml = simplexml_load_string("<datasets></datasets>");
             $xmlDoc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "data.xml", $xml->asXML(), "text/xml");
             $xmlDoc->move($mplme);
         } else {
             $xmlRaw = $xmlDoc->get_content();
             $xml = simplexml_load_string($xmlRaw);
         }
         $xmlRequest = simplexml_load_string($_REQUEST["xmlData"]);
         $xmlRequestDom = new \domDocument();
         $xmlRequestDom->loadXML($xmlRequest->asXML());
         $xmlDom = new \domDocument();
         $xmlDom->loadXML($xml->asXML());
         $xmlDom->documentElement->appendChild($xmlDom->importNode($xmlRequestDom->documentElement, true));
         if ($_FILES && is_array($_FILES)) {
             foreach ($_FILES as $file) {
                 $content = file_get_contents($file["tmp_name"]);
                 $doc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $file["name"], $content, $file["type"]);
                 $doc->move($mplme);
             }
         }
         $xmlDoc->set_content($xmlDom->saveXML());
         //echo "<pre>" . htmlentities($xmlDom->saveXML()) . "</pre>";
         echo "ok";
     } else {
         echo "nix";
     }
     die;
     //echo "done";
     //$frameResponseObject->addWidget(new \Widgets\Blank());
     //return $frameResponseObject;
 }
开发者ID:rolwi,项目名称:koala,代码行数:38,代码来源:Upload.class.php

示例2: run

 public function run($str = nULL)
 {
     if (!is_null($str)) {
         $regex = '/<([a-z0-9\\-]+)(.*?)>(?:(.*?)(<\\/\\1>))?/ix';
         if (is_a($str, jqmel)) {
             $str = $str->dom()->get()->lastdom;
         } elseif (is_callable($str)) {
             $str = call_user_func($str, array());
         }
         $str = preg_replace('/\\s+/', ' ', $str);
         if (preg_match($regex, $str, $match)) {
             $match[2] = rtrim($match[2], '/');
         }
         $document = jqm_use($this->node->_parentElement);
         $np = $this->node->next()->get();
         $npp = $this->node->prev()->get();
         $par = $this->node->parent();
         $wrap = $str;
         if (!is_a($par->get(), jqmel)) {
             return;
         }
         $rec = $document->_DOM;
         if ($rec->doctype) {
             $rec->removeChild($rec->doctype);
         }
         $xpath = new domxpath($rec);
         $find = $xpath->query($this->node->_path);
         if ($find->length > 0) {
             $child = new domDocument();
             $child->loadHtml($wrap);
             if ($child->doctype) {
                 $child->removeChild($child->doctype);
             }
             $chf = $child->getElementsByTagName($match[1]);
             $node = $this->node->__toDomElement();
             $frag = $child->importNode($node, true);
             $depth = $this->getDeepest($chf->item(0));
             $save = $depth->appendChild($frag);
             //Import to document
             $frag = $rec->importNode($chf->item(0), true);
             $newsave = $find->item(0)->parentNode->replaceChild($frag, $find->item(0));
             $new_path = explode('/', $frag->getNodePath());
             $p_path = array_filter(explode('/', $save->getNodePath()));
             //$p_path = array_pop($p_path);
             $htm = array_search('html', $p_path);
             if ($htm) {
                 unset($p_path[$htm]);
                 unset($p_path[$htm + 1]);
             }
             $new_path = array_merge($new_path, $p_path);
             $sh = array_pop($new_path);
             array_pop($new_path);
             $ele_path = ltrim($newsave->getNodePath(), '/');
             $this->node->_parent_path = implode('/', $new_path);
             $this->node->_path = $this->node->_parent_path . '/' . $sh;
             $wrap = $rec->saveHtml($frag->parentNode);
             $wrap = substr($wrap, strpos($wrap, '>') + 1);
             if (!empty($par->get()->_localName)) {
                 $wrap = substr($wrap, 0, strripos($wrap, $par->get()->_localName));
                 $par->get()->html($wrap);
             }
             $find = $this->node->getPathById();
             if ($find) {
                 $this->node->_path = $find;
             }
             if ($this->node->trace) {
                 $key = $this->node->trace->key();
                 $this->node->trace->next();
                 $n = $this->node->trace->current();
                 if ($key > 0) {
                     $this->node->trace->seek($key - 1);
                     $p = $this->node->trace->current();
                 }
                 if ($p and is_a($p, jqmel)) {
                     $find = $p->getPathById();
                     if ($find) {
                         $p->_path = $find;
                         //var_dump($key,$p);
                     }
                 }
                 if ($n and is_a($n, jqmel)) {
                     $find = $n->getPathById();
                     if ($find) {
                         $n->_path = $find;
                     }
                 }
                 unset($p);
                 unset($n);
             }
         }
     }
 }
开发者ID:Webictbyleo,项目名称:JqueryPhp,代码行数:92,代码来源:wrap.php


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