本文整理汇总了PHP中XMLElement::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLElement::getName方法的具体用法?PHP XMLElement::getName怎么用?PHP XMLElement::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromXML
/**
* Instantiates Services_Gnip_Publisher with current class data values
*
* @access public
* @param XMLElement $xml XML Publisher
* @return Services_Gnip_Publisher Services_Gnip_Publisher object
*/
function fromXML($xml)
{
if ($xml->getName() != "publisher") {
throw new Exception("expected publisher");
}
return new Services_Gnip_Publisher($xml["name"]);
}
示例2: FactoryFromXMLElement
public static function FactoryFromXMLElement(XMLElement $element)
{
if ($element->getName() == 'CommonPrefixes') {
return self::FactoryFromCommonPrefixes($element);
}
if ($element->getName() == 'Contents') {
return self::FactoryFromContents($element);
}
}
示例3: addElementToHead
/**
* Adds an XMLElement to the `$this->_head` array at a desired position.
* If no position is given, the object will be added to the end
* of the `$this->_head` array. If that position is already taken, it will
* add the object at the next available position.
*
* @see toolkit.General#array_find_available_index()
* @param XMLElement $object
* @param integer $position
* Defaults to null which will put the `$object` at the end of the
* `$this->_head`.
* @param boolean $allowDuplicate
* If set to false, make this function check if there is already an XMLElement that as the same name in the head.
* Defaults to true. @since Symphony 2.3.2
* @return integer
* Returns the position that the `$object` has been set in the `$this->_head`
*/
public function addElementToHead(XMLElement $object, $position = null, $allowDuplicate = true)
{
// find the right position
if ($position && isset($this->_head[$position])) {
$position = General::array_find_available_index($this->_head, $position);
} elseif (is_null($position)) {
if (count($this->_head) > 0) {
$position = max(array_keys($this->_head)) + 1;
} else {
$position = 0;
}
}
// check if we allow duplicate
if (!$allowDuplicate && !empty($this->_head)) {
$this->removeFromHead($object->getName());
}
// append new element
$this->_head[$position] = $object;
return $position;
}
示例4: getChildrenWithClass
private function getChildrenWithClass(XMLElement &$rootElement, $className, $tagName = null)
{
if ($rootElement == null) {
return null;
}
// contains the right css class and the right node name (if any)
// TODO: Use word bondaries instead of strpos
if ((!$className || strpos($rootElement->getAttribute('class'), $className) > -1) && (!$tagName || $rootElement->getName() == $tagName)) {
return $rootElement;
}
// recursive search in child elements
foreach ($rootElement->getChildren() as $key => $child) {
if (!$child instanceof XMLElement) {
continue;
}
$res = $this->getChildrenWithClass($child, $className, $tagName);
if ($res != null) {
return $res;
}
}
return null;
}