Heim >Backend-Entwicklung >PHP-Tutorial > 如何能知道XML对象中有几个一层的元素 simplexml_load_file()

如何能知道XML对象中有几个一层的元素 simplexml_load_file()

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:34:48808Durchsuche

怎么能知道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 />

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn