PHPSimpleXML. Compared with the DOM or Expat parser, SimpleXML can read text data from elements with just a few lines of code. SimpleXML can convert an XML document to an object. for example, compared with the DOM or Expat parser, SimpleXML can read text data from an element with just a few lines of code.
SimpleXML converts an XML document to an object.For example:
Element-a single attribute of the SimpleXMLElement object. When multiple elements exist at the same level, they are placed in an array.
Attribute-access by using an associated array. the subscript corresponds to the attribute name.
Element data-text data from an element is converted to a string. If an element has multiple text nodes, they are arranged in the order they are found.
SimpleXML is quick to use when you execute basic tasks similar to the following:
Read XML files
Extract data from XML strings
Edit a text node or attribute
However, when processing advanced XML, such as namespaces, it is best to use the Expat parser or xml dom.
SimpleXML functions are a core component of PHP. You can use these functions without installation.
XML file:
George
John
Reminder
Don't forget the meeting!
PHP:
getName() . "
";foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "
"; }?>
Compared with the external DOM or Expat parser, SimpleXML can read text data from elements with just a few lines of code. SimpleXML can be used to convert an XML document to an object, for example, element-converted...