PHP 5 SimpleXML Functions

PHP SimpleXML Introduction

SimpleXML is an augmentation that enables us to effectively control and get XML data.

SimpleXML gives a simple method for getting a component's name, traits and literary substance on the off chance that you realize the XML report's structure or layout.

SimpleXML transforms a XML report into an information structure you can emphasize through like a gathering of exhibits and objects.


As of PHP 5, the SimpleXML capacities are a piece of the PHP center. No establishment is required to utilize these functions.

PHP 5 SimpleXML Functions

Function Description
__construct() Creates another SimpleXMLElement object
addAttribute() Adds a credit to the SimpleXML element
addChild() Adds a youngster component the SimpleXML element
asXML() Returns an all around shaped XML string (XML rendition 1.0) from a SimpleXML object
attributes() Returns the properties/estimations of an element
children() Returns the offspring of a predetermined node
count() Counts the offspring of a predetermined node
getDocNamespaces() Returns the namespaces DECLARED in document
getName() Returns the name of the XML label referenced by the SimpleXML element
getNamespaces() Returns the namespaces USED in document
registerXPathNamespace() Creates a namespace setting for the following XPath query
saveXML() Alias of asXML()
simplexml_import_dom() Returns a SimpleXMLElement object from a DOM node
simplexml_load_file() Converts a XML document into a SimpleXMLElement object
simplexml_load_string() Converts a XML string into a SimpleXMLElement object
xpath() Runs a XPath inquiry on XML data

PHP 5 SimpleXML Iteration Functions

Function Description
current() Returns the current element
getChildren() Returns the kid components of the current element
hasChildren() Checks whether the present component has children
key() Return the current key
next() Moves to the following element
rewind() Rewind to the first element
valid() Check whether the present component is valid