The SimpleXMLIterator class

Introduction

The SimpleXMLIterator provides recursive iteration over all nodes of a SimpleXMLElement object.

Class synopsis

SimpleXMLIterator
extends SimpleXMLElement
/* Inherited methods */
public __construct(
    string $data,
    int $options = 0,
    bool $dataIsURL = false,
    string $namespaceOrPrefix = "",
    bool $isPrefix = false
)
public void addAttribute(string $qualifiedName, string $value, stringnull $namespace = null)
public SimpleXMLElementnull addChild(string $qualifiedName, stringnull $value = null, stringnull $namespace = null)
public stringbool asXML(stringnull $filename = null)
public SimpleXMLElementnull attributes(stringnull $namespaceOrPrefix = null, bool $isPrefix = false)
public SimpleXMLElementnull children(stringnull $namespaceOrPrefix = null, bool $isPrefix = false)
public int count()
public SimpleXMLElement current()
public arrayfalse getDocNamespaces(bool $recursive = false, bool $fromRoot = true)
public string getName()
public array getNamespaces(bool $recursive = false)
public SimpleXMLElementnull getChildren()
public bool hasChildren()
public string key()
public void next()
public bool registerXPathNamespace(string $prefix, string $namespace)
public void rewind()
public string __toString()
public bool valid()
public arraynullfalse xpath(string $expression)

Changelog

Version Description
8.0.0 Iterator methods ( SimpleXMLIterator::hasChildren, SimpleXMLIterator::getChildren, SimpleXMLIterator::current, SimpleXMLIterator::key, SimpleXMLIterator::next, SimpleXMLIterator::rewind, SimpleXMLIterator::valid) were moved to SimpleXMLElement.
8.0.0 SimpleXMLIterator implements Stringable now.