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