Compared to DOM or Expat parsers, SimpleXML can read text data from elements in just a few lines of code.
SimpleXML can convert XML documents to objects , such as:
Element-is converted to a single attribute of the SimpleXMLElement object. When multiple elements exist at the same level, they are placed in the array.
Property-accessed by using an associative array, where the subscript corresponds to the property name.
element data-text data from an element is converted to a string. If an element has more than one text node, it is arranged in the order in which they are found.
SimpleXML is very quick to use when performing basic tasks like the following:
Reading an XML file
Extracting data from an XML string
Edit a text node or property
However, when working with advanced XML, such as namespaces, it is best to use the Expat parser or the XML DOM.
The SimpleXML function is part of the PHP core. These functions can be used without installation.
XML file:
George
John
Reminder
Don ' t forget the meeting!
Php:
GetName (). "
"; foreach ($xml->children () as $child) { echo $child->getname ().": ". $child. "
"; }? >
http://www.bkjia.com/PHPjc/755781.html www.bkjia.com true http://www.bkjia.com/PHPjc/755781.html techarticle compared to DOM or Expat parsers, SimpleXML can read text data from elements in just a few lines of code. SimpleXML can convert an XML document to an object, such as an element-to be converted ...