xref: /PHP-7.1/ext/simplexml/tests/bug62639.phpt (revision 113213f0)
1--TEST--
2Bug #62639 (XML structure broken)
3--SKIPIF--
4<?php
5if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6?>
7--FILE--
8<?php
9
10class A extends SimpleXMLElement
11{
12}
13
14$xml1 = <<<XML
15<?xml version="1.0"?>
16<a>
17    <b>
18        <c>
19            <value attr="Some Attr">Some Value</value>
20        </c>
21    </b>
22</a>
23XML;
24
25$a1 = new A($xml1);
26
27foreach ($a1->b->c->children() as $key => $value) {
28    var_dump($value);
29}
30
31$xml2 = <<<XML
32<?xml version="1.0"?>
33<a>
34    <b>
35        <c><value attr="Some Attr">Some Value</value></c>
36    </b>
37</a>
38XML;
39
40$a2 = new A($xml2);
41
42foreach ($a2->b->c->children() as $key => $value) {
43    var_dump($value);
44}?>
45--EXPECT--
46object(A)#2 (2) {
47  ["@attributes"]=>
48  array(1) {
49    ["attr"]=>
50    string(9) "Some Attr"
51  }
52  [0]=>
53  string(10) "Some Value"
54}
55object(A)#3 (2) {
56  ["@attributes"]=>
57  array(1) {
58    ["attr"]=>
59    string(9) "Some Attr"
60  }
61  [0]=>
62  string(10) "Some Value"
63}
64