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


PHP XMLElement::replaceChildAt方法代码示例

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


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

示例1: insertAction

 /**
  * This function allows a user to insert an Action button to the page.
  * It accepts an `XMLElement` (which should be of the `Anchor` type),
  * an optional parameter `$prepend`, which when `true` will add this
  * action before any existing actions.
  *
  * @since Symphony 2.3
  * @see core.Widget#Anchor
  * @param XMLElement $action
  *  An Anchor element to add to the top of the page.
  * @param boolean $append
  *  If true, this will add the `$action` after existing actions, otherwise
  *  it will be added before existing actions. By default this is `true`,
  *  which will add the `$action` after current actions.
  */
 public function insertAction(XMLElement $action, $append = true)
 {
     $actions = $this->Context->getChildrenByName('ul');
     // Actions haven't be added yet, create the element
     if (empty($actions)) {
         $ul = new XMLElement('ul', NULL, array('class' => 'actions'));
         $this->Context->appendChild($ul);
     } else {
         $ul = current($actions);
         $this->Context->replaceChildAt(1, $ul);
     }
     $li = new XMLElement('li', $action);
     if ($append) {
         $ul->prependChild($li);
     } else {
         $ul->appendChild($li);
     }
 }
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:33,代码来源:class.administrationpage.php

示例2: findEntries

 private function findEntries(XMLElement $xml)
 {
     // check if xml has child elements
     if (($elements = $xml->getChildren()) && is_array($elements)) {
         // handle elements
         foreach ($elements as $element_index => $element) {
             // check if element is xml element
             if ($element instanceof XMLElement) {
                 // check if element is entry
                 if ($element->getName() === 'entry') {
                     // process fields
                     $element = $this->processFields($element);
                 } else {
                     // find entries
                     $element = $this->findEntries($element);
                 }
                 // replace element
                 $xml->replaceChildAt($element_index, $element);
             }
         }
     }
     return $xml;
 }
开发者ID:ShinShinman,项目名称:multilingual,代码行数:23,代码来源:extension.driver.php


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