SimpleXMLElement
class SimpleXMLElement implements Traversable, ArrayAccess, Countable, Iterator, Stringable, RecursiveIterator (View source)
Represents an element in an XML document.
Methods
Creates a new SimpleXMLElement object
Return a well-formed XML string based on SimpleXML element
Alias of SimpleXMLElement::asXML Return a well-formed XML string based on SimpleXML element
Runs XPath query on XML data
Creates a prefix/ns context for the next XPath query
Identifies an element's attributes
Finds children of given node
Returns namespaces used in document
Returns namespaces declared in document
Gets the name of the XML element
Adds a child element to the XML node
Adds an attribute to the SimpleXML element
Returns the string content
Counts the children of an element
Class provides access to children by position, and attributes by name private Method not callable directly, stub exists for typehint only
Class provides access to children by position, and attributes by name private Method not callable directly, stub exists for typehint only
Class provides access to children by position, and attributes by name private Method not callable directly, stub exists for typehint only
Class provides access to children by position, and attributes by name private Method not callable directly, stub exists for typehint only
Rewind to the first element
Check whether the current element is valid
Returns the current element
Return current key
Move to next element
No description
No description
Details
__construct(string $data, int $options = 0, bool $dataIsURL = false, string $namespaceOrPrefix = "", bool $isPrefix = false)
Creates a new SimpleXMLElement object
string|bool
asXML(string $filename = null)
Return a well-formed XML string based on SimpleXML element
string|bool
saveXML(string $filename = null)
Alias of SimpleXMLElement::asXML Return a well-formed XML string based on SimpleXML element
array|false|null
xpath(string $expression)
Runs XPath query on XML data
bool
registerXPathNamespace(string $prefix, string $namespace)
Creates a prefix/ns context for the next XPath query
SimpleXMLElement|null
attributes(string $namespaceOrPrefix = null, bool $isPrefix = false)
Identifies an element's attributes
SimpleXMLElement|null
children(string $namespaceOrPrefix = null, bool $isPrefix = false)
Finds children of given node
array
getNamespaces(bool $recursive = false)
Returns namespaces used in document
array|false
getDocNamespaces(bool $recursive = false, bool $fromRoot = true)
Returns namespaces declared in document
string
getName()
Gets the name of the XML element
SimpleXMLElement|null
addChild(string $qualifiedName, string $value = null, string $namespace = null)
Adds a child element to the XML node
void
addAttribute(string $qualifiedName, string $value, string $namespace = null)
Adds an attribute to the SimpleXML element
string
__toString()
Returns the string content
int
count()
Counts the children of an element
bool
offsetExists(TKey $offset)
Class provides access to children by position, and attributes by name private Method not callable directly, stub exists for typehint only
mixed
offsetGet(TKey $offset)
Class provides access to children by position, and attributes by name private Method not callable directly, stub exists for typehint only
void
offsetSet(TKey $offset, TValue $value)
Class provides access to children by position, and attributes by name private Method not callable directly, stub exists for typehint only
void
offsetUnset(TKey $offset)
Class provides access to children by position, and attributes by name private Method not callable directly, stub exists for typehint only
void
rewind()
Rewind to the first element
bool
valid()
Check whether the current element is valid
mixed
current()
Returns the current element
mixed
key()
Return current key
void
next()
Move to next element
bool
hasChildren()
No description
RecursiveIterator|null
getChildren()
No description