The SimpleXML extension provides a simple way to get the name and text of an XML element, as long as you know the layout of the XML document.
SimpleXML converts XML documents into SimpleXMLElement objects.
This object can be processed like any other object via normal property selectors and array iterators.
Tip: Compared to DOM or Expat parsers, SimpleXML only requires a few lines of code to read the text data in an element.
The SimpleXML extension requires PHP 5 support.
Since PHP 5, SimpleXML functions are part of the core of PHP. No installation is required to use these functions.
function | describe |
---|---|
__construct() | Create a new SimpleXMLElement object. |
addAttribute() | Add an attribute to the SimpleXML element. |
addChild() | Add a child element to the SimpleXML element. |
asXML() | Format data for SimpleXML objects in XML (version 1.0). |
attributes() | Returns the attributes and values of the XML tag. |
children() | Finds the child nodes of the specified node. |
count() | Count the number of child nodes of the specified node. |
getDocNamespaces() | Returns the declared namespace in the document. |
getName() | Returns the name of the XML tag referenced by the SimpleXML element. |
getNamespaces() | Returns the namespace used in the document. |
registerXPathNamespace() | Create a namespace context for the next XPath query. |
saveXML() | Alias for asXML(). |
simplexml_import_dom() | Returns a SimpleXMLElement object from a DOM node. |
simplexml_load_file() | Convert XML files into SimpleXMLElement objects. |
simplexml_load_string() | Converts an XML string to a SimpleXMLElement object. |
xpath() | Run XPath queries on XML data. |
function | describe |
---|---|
current() | Returns the current element. |
getChildren() | Returns the child elements of the current element. |
hasChildren() | Checks if the current element has child elements. |
key() | Returns the current key. |
next() | Move to the next element. |
rewind() | Rewind to the first element. |
valid() | Checks whether the current element is valid. |