Article · Wikipedia archive · Last revised May 28, 2026

SimpleXML

SimpleXML is a PHP extension that allows users to easily manipulate/use XML data. It was introduced in PHP 5 as an object oriented approach to the XML DOM providing an object that can be processed with normal property selectors and array iterators. It represents an easy way of getting an element's attributes and textual content if you know the XML document's structure or layout.

Last revised
May 28, 2026
Read time
≈ 1 min
Length
200 w
Citations
9
Source

SimpleXML is a PHP extension that allows users to easily12 manipulate/use XML data. It was introduced in PHP 5 as an object oriented approach to the XML DOM providing an object that can be processed with normal property selectors and array iterators.34 It represents an easy way of getting an element's attributes and textual content if you know the XML document's structure or layout.5

Compared to DOM or the Expat parser, SimpleXML takes a fewer lines of code to read text data from an element.67

Functions

  • addAttribute()8
  • addChild()
  • asXML()
  • attributes()
  • children()
  • __construct()
  • getDocNamespaces()
  • getName()
  • getNamespaces()
  • registerXPathNamespace()
  • xpath()
  • simplexml_import_dom
  • simplexml_load_file
  • simplexml_load_string

Error handling

It is possible to suppress all XML errors when loading the document and then iterate over the errors.9

References

References

External links