XMLElement
MMO\core\helpers · 1 symbol · generated 30 Sep 2026
XMLElement
XMLElement.php:16SimpleXMLElement wrapper, adding: namespace-prefixed attribute/child access ('ns:name'), parent/sibling navigation, a self-contained toXML serializer, and various convenience mutators SimpleXMLElement itself lacks (setAttribute, addElement, removeAttribute, ...).
- Namespace
MMO\core\helpers- Extends
- SimpleXMLElement
Index
| addElement($tag, $attributes, $children) | Add child element (prefix supported) | |
| addNamespace($prefix, $namespace) | Declare a namespace on this element (xmlns:$prefix="$namespace"), without leaving a dummy attribute behind (a standard SimpleXML add-then-unset trick). | |
| addXML($xml, $namespace) | Add xml to this node | |
| clear() | Clear node | |
| FromFile($filename, $options, $namespace_or_prefix, $is_prefix) static | ||
| FromString($xml, $options, $namespace_or_prefix, $is_prefix) static | ||
| getAllChildren() | ||
| getAttribute($name) | Get attribute and prefixed attribute's value as a string. | |
| getAttributes($namespace, $isPrefix) | ||
| getBoolAttribute($name) | Get boolean attribute (prefix supported). | |
| getChild($tag) | ||
| getInnerText() | Get inner text (ignore all children) | |
| getName($withPrefix) | Override so you can get the name with the prefix | |
| getNextSibling() | ||
| getParentNode() | ||
| getPreviousSibling() | ||
| remove() | Remove node from xml | |
| removeAttribute($name) | Remove attribute (prefix supported) | |
| reorderNodes($fn) | Reorder nodes using a function | |
| reorderNodesByTag($tagOrder) | Reorders child nodes according to a given tag order list. | |
| setAttribute($name, $value) | Set attribute's value (prefix supported). | |
| setAttributes($attributes) | Set multiple attributes (prefix supported) | |
| setInnerText($text) | Set inner text and replace all children by the text | |
| toXML($declaredNs, $indent) | Export node to xml |
Methods24
addElement($tag, $attributes, $children)
XMLElement.php:247Add child element (prefix supported)
| $tag | string | |
| $attributes = [] | array | |
| ...$children | SimpleXMLElement | string | |
| returns | static |
addNamespace($prefix, $namespace)
XMLElement.php:80Declare a namespace on this element (xmlns:$prefix="$namespace"), without leaving a dummy attribute behind (a standard SimpleXML add-then-unset trick). NOTE: due to a SimpleXML quirk, getNamespaces may not immediately reflect the new declaration without re-parsing the XML -- asXML / toXML output does include it right away.
addXML($xml, $namespace)
XMLElement.php:276Add xml to this node
| $xml | SimpleXMLElement | string | |
| $namespace = null | null | string | |
| returns | self | the created node |
clear()
XMLElement.php:233Clear node
| returns | self |
FromFile($filename, $options, $namespace_or_prefix, $is_prefix)
staticXMLElement.php:36FromString($xml, $options, $namespace_or_prefix, $is_prefix)
staticXMLElement.php:24getAllChildren()
XMLElement.php:216| returns | array | every direct child element, across every namespace used |
getAttribute($name)
XMLElement.php:340Get attribute and prefixed attribute's value as a string.
getAttributes($namespace, $isPrefix)
XMLElement.php:308getBoolAttribute($name)
XMLElement.php:357Get boolean attribute (prefix supported).
getChild($tag)
XMLElement.php:203| $tag | string | a plain tag name, or a 'prefix:tag' for a namespaced one |
| returns | null | self | the first direct child with this tag, or null if none matches |
getInnerText()
XMLElement.php:101Get inner text (ignore all children)
| returns | string |
getName($withPrefix)
XMLElement.php:62Override so you can get the name with the prefix
getNextSibling()
XMLElement.php:46getParentNode()
XMLElement.php:41| returns | self | the parent element (via an XPath 'parent::*' query) |
getPreviousSibling()
XMLElement.php:51remove()
XMLElement.php:109Remove node from xml
| returns | void |
removeAttribute($name)
XMLElement.php:407Remove attribute (prefix supported)
reorderNodes($fn)
XMLElement.php:171Reorder nodes using a function
reorderNodesByTag($tagOrder)
XMLElement.php:187Reorders child nodes according to a given tag order list.
setAttribute($name, $value)
XMLElement.php:381Set attribute's value (prefix supported).
setAttributes($attributes)
XMLElement.php:368Set multiple attributes (prefix supported)
setInnerText($text)
XMLElement.php:92Set inner text and replace all children by the text
toXML($declaredNs, $indent)
XMLElement.php:122Export node to xml
| $declaredNs = [] | array | Namespaces already declared in ancestor elements |
| $indent = 0 | null | int | Current indentation level. if null print everything on same line |
| returns | string |
Inherited members (21)
| Methods | Declared by | Description | |
|---|---|---|---|
addAttribute($qualifiedName, $value, $namespace) | SimpleXMLElement | ||
addChild($qualifiedName, $value, $namespace) | SimpleXMLElement | ||
asXML($filename) | SimpleXMLElement | ||
attributes($namespaceOrPrefix, $isPrefix) | SimpleXMLElement | ||
children($namespaceOrPrefix, $isPrefix) | SimpleXMLElement | ||
count() | SimpleXMLElement | ||
current() | SimpleXMLElement | ||
getChildren() | SimpleXMLElement | ||
getDocNamespaces($recursive, $fromRoot) | SimpleXMLElement | ||
getNamespaces($recursive) | SimpleXMLElement | ||
hasChildren() | SimpleXMLElement | ||
key() | SimpleXMLElement | ||
next() | SimpleXMLElement | ||
registerXPathNamespace($prefix, $namespace) | SimpleXMLElement | ||
rewind() | SimpleXMLElement | ||
saveXML($filename) | SimpleXMLElement | ||
valid() | SimpleXMLElement | ||
xpath($expression) | SimpleXMLElement | ||
__construct($data, $options, $dataIsURL, $namespaceOrPrefix, $isPrefix) | SimpleXMLElement | ||
__debugInfo() | SimpleXMLElement | ||
__toString() | SimpleXMLElement |