PHP Function Reference

PHP - SimpleXML

The SimpleXML extension provides a very simple and easily usable toolset that allows us to easily manipulate and get XML data. It provides an easy way of getting an element's name, attributes and textual content if you know the XML document's structure or layout. SimpleXML turns an XML document into a data structure that can be iterated through like a collection of arrays and objects.


There is no installation needed to use this extension. This extension is a part of the PHP core. This extension is enabled by default. It may be disabled by using the following option at compile time: --disable-simplexml.

The SimpleXMLElement class

count() Counts the children of an element.

The SimpleXMLIterator class

current() Returns the current element.
next() Move to next element.
rewind() Rewind to the first element.
valid() Check whether the current element is valid.

The SimpleXML Functions

simplexml_load_file() Interprets an XML file into an object.