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


PHP DOMElement::replaceChild方法代码示例

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


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

示例1: insertImageData

 /**
  * Inserts $imageData as a child into $imageObject.
  *
  * Detects if $imageObject contains <office:binary-data/>. If this is the case, 
  * this element is replaced with the given $imageData. Otherwise, 
  * $imageData is added as a new child.
  * 
  * @param DOMElement $imageObject 
  * @param DOMElement $imageData 
  */
 protected function insertImageData($imageObject, $imageData)
 {
     $binaryDataElems = $imageObject->getElementsByTagNameNS(ezcDocumentOdt::NS_ODT_OFFICE, 'binary-data');
     if ($binaryDataElems->length === 1) {
         $imageObject->replaceChild($imageData, $binaryDataElems->item(0));
     } else {
         $imageObject->appendChild($imageData);
     }
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:19,代码来源:image.php

示例2: SetTitre

 /**
  *
  * @param string $titre
  */
 public function SetTitre($titre)
 {
     $set = $this->document->createTextNode($titre);
     $this->elementTitle->replaceChild($set, $this->textTitre);
     $this->textTitre = $set;
     // Si seulement cette fonction était implémenté...
     //$this->textTitre->replaceWholeText($titre);
 }
开发者ID:TheProjecter,项目名称:qyy-php-misc,代码行数:12,代码来源:GabaritXhtmlTransitional.class.php

示例3: replaceChild

 /**
  * (PHP 5)<br/>
  * Replaces a child
  * @link http://php.net/manual/en/domnode.replacechild.php
  * @param DOMNode $newnode <p>
  * The new node. It must be a member of the target document, i.e.
  * created by one of the DOMDocument->createXXX() methods or imported in
  * the document by .
  * </p>
  * @param DOMNode $oldnode <p>
  * The old node.
  * </p>
  * @return DOMNode The old node or false if an error occur.
  */
 public function replaceChild(\DOMNode $newnode, \DOMNode $oldnode)
 {
     $newNode = parent::replaceChild($newnode, $oldnode);
     return $newNode;
 }
开发者ID:charlanalves,项目名称:sped,代码行数:19,代码来源:Element.php

示例4: replaceChild

 /**
  * Replaces a directive.
  * 
  * @param HTTPd_DOMElement $newnode
  * @param HTTPd_DOMElement $oldnode
  * @return HTTPd_DOMElement
  */
 public function replaceChild(\DOMNode $newnode, \DOMNode $oldnode)
 {
     if ($newnode instanceof \DOMAttr || $oldnode instanceof \DOMAttr) {
         throw new \DOMException("Don't call Q\\HTTPd_DOMElement::" . __FUNCTION__ . "() to replace an attribute, use setAttribute() or setAttributeNode() instead.", DOM_HIERARCHY_REQUEST_ERR);
     }
     if ($this->firstChild === null) {
         throw new \DOMException("It's not possible to add children to {$this->nodeName} direcive.", DOM_HIERARCHY_REQUEST_ERR);
     }
     if (!$newnode instanceof HTTPd_DOMElement && !$newnode instanceof HTTPd_DOMComment && !$newnode instanceof \DOMText) {
         throw new \DOMException("You may only add Q\\HTTPd_DOMElement, Q\\HTTPd_DOMComment and DOMText nodes to a section, not a " . get_class($newnode) . ".", DOM_HIERARCHY_REQUEST_ERR);
     }
     return \DOMElement::replaceChild($newnode, $oldnode);
 }
开发者ID:jasny,项目名称:Q,代码行数:20,代码来源:DOMElement.php

示例5: extendItemAndGetChangedTime

 /**
  * Extends one item with the full content of the specified link
  *
  * @param Feed       $feed
  * @param DOMElement $domElement
  * @param bool       $useCache
  * @return int
  */
 private function extendItemAndGetChangedTime(Feed $feed, DOMElement $domElement, $useCache)
 {
     /** @var $contentNodes DOMElement[] */
     $contentNodes = array();
     $link = "";
     $time = 0;
     foreach ($domElement->childNodes as $child) {
         /** @var $child DOMElement */
         $name = $child->nodeName;
         $value = $child->nodeValue;
         if ($name == "link") {
             $link = $value;
             if ($link == "") {
                 $link = $child->getAttribute("href");
             }
         } else {
             if (in_array($name, $this->contentNames)) {
                 $contentNodes[] = $child;
             } else {
                 if (in_array($name, $this->timeNames)) {
                     $time = strtotime($value);
                 }
             }
         }
     }
     $filteredContent = $this->getFilteredContentOfUrl($feed, $link, $useCache, $time);
     foreach ($contentNodes as $contentNode) {
         // replace old with new content
         if ($filteredContent != "") {
             $newNode = $contentNode->ownerDocument->createElement($contentNode->nodeName);
             $newNode->setAttribute("type", "html");
             $textNode = $contentNode->ownerDocument->createTextNode($filteredContent);
             $newNode->appendChild($textNode);
             foreach ($contentNode->attributes as $attrName => $attrNode) {
                 @$newNode->setAttribute($attrName, $attrNode);
             }
             $domElement->replaceChild($newNode, $contentNode);
         } else {
             @($contentNode->nodeValue .= "\n\n<br /><br /><span style='font: #ff0000'>WARNING! Your Rss-Extender rules returned an empty string for link: " . $link . "</span>");
         }
     }
     return $time;
 }
开发者ID:danielniedermeyer,项目名称:rss-extender,代码行数:51,代码来源:RssExtender.php


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