xref: /PHP-5.3/ext/simplexml/tests/022.phpt (revision 610c7fbe)
1--TEST--
2SimpleXML: Attributes inside foreach
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7
8$xml =<<<EOF
9<?xml version='1.0'?>
10<pres><content><file glob="slide_*.xml"/></content></pres>
11EOF;
12
13$sxe = simplexml_load_string($xml);
14
15echo "===CONTENT===\n";
16var_dump($sxe->content);
17
18echo "===FILE===\n";
19var_dump($sxe->content->file);
20
21echo "===FOREACH===\n";
22foreach($sxe->content->file as $file)
23{
24	var_dump($file);
25	var_dump($file['glob']);
26}
27
28?>
29===DONE===
30--EXPECTF--
31===CONTENT===
32object(SimpleXMLElement)#%d (1) {
33  ["file"]=>
34  object(SimpleXMLElement)#%d (1) {
35    ["@attributes"]=>
36    array(1) {
37      ["glob"]=>
38      string(11) "slide_*.xml"
39    }
40  }
41}
42===FILE===
43object(SimpleXMLElement)#%d (1) {
44  ["@attributes"]=>
45  array(1) {
46    ["glob"]=>
47    string(11) "slide_*.xml"
48  }
49}
50===FOREACH===
51object(SimpleXMLElement)#%d (1) {
52  ["@attributes"]=>
53  array(1) {
54    ["glob"]=>
55    string(11) "slide_*.xml"
56  }
57}
58object(SimpleXMLElement)#%d (1) {
59  [0]=>
60  string(11) "slide_*.xml"
61}
62===DONE===
63