怎么能知道XML对象中有几个一层的元素 simplexml_load_file()
比如:simplexml_load_file() 后用var_dump()显示如下:
怎么能知道xml中包含几个page ?
下例中page是2个,一个[0],一个[1].
<br /> object(SimpleXMLElement)#24 (1) <br /> { <br /> ["page"]=> array(2) <br /> { <br /> [0]=> object(SimpleXMLElement)#25 (2) <br /> { <br /> ["@attributes"]=> array(1) <br /> { <br /> ["id"]=> string(1) "0" <br /> } <br /> ["background"]=> object(SimpleXMLElement)#38 (1) <br /> { <br /> ["@attributes"]=> array(1) <br /> { <br /> ["color"]=> string(11) "255,255,255" <br /> } <br /> } <br /> } <br /> [1]=> object(SimpleXMLElement)#26 (1) <br /> { <br /> ["@attributes"]=> array(1) <br /> { <br /> ["preview"]=> string(100) "" <br /> <br /> } <br /> } <br /> }<br /> }<br /> <br />