How can we know that the XML object contains several layers of elements simplexml_load_file (), such as simplexml_load_file (), and then var_dump () is shown as follows:
How many pages are contained in xml?
In the following example, there are two pages, one [0] and the other [1].
object(SimpleXMLElement)#24 (1) { ["page"]=> array(2) { [0]=> object(SimpleXMLElement)#25 (2) { ["@attributes"]=> array(1) { ["id"]=> string(1) "0" } ["background"]=> object(SimpleXMLElement)#38 (1) { ["@attributes"]=> array(1) { ["color"]=> string(11) "255,255,255" } } } [1]=> object(SimpleXMLElement)#26 (1) { ["@attributes"]=> array(1) { ["preview"]=> string(100) "" } } }}
Reply to discussion (solution)
$elem = simplexml_load_string($xml);var_dump($elem->count());
$elem = simplexml_load_string($xml);var_dump($elem->count());
Thank you. This function is only supported by php5.3 and above. I upgraded my 5.2 to 5.5 yesterday. However, it will be slow to refresh the page after it is opened-very slow
$elem = simplexml_load_string($xml);var_dump($elem->count());
Thank you. This function is only supported by php5.3 and above. I upgraded my 5.2 to 5.5 yesterday. However, it will be slow to refresh the page after it is opened-very slow
5.5 some functions are not backward compatible.
However, it should be faster than the previous version.