xref: /PHP-8.1/ext/simplexml/tests/profile12.phpt (revision 7f2f0c00)
1--TEST--
2SimpleXML [profile]: Accessing namespaced root and non namespaced children
3--EXTENSIONS--
4simplexml
5--FILE--
6<?php
7
8$xml =<<<EOF
9<?xml version="1.0" encoding="utf-8"?>
10<soap:Envelope
11xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
12xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13xmlns:xsd="http://www.w3.org/2001/XMLSchema"
14>
15<soap:Body>
16<businessList foo="bar">
17<businessInfo businessKey="bla"/>
18</businessList>
19</soap:Body>
20</soap:Envelope>
21EOF;
22
23$sxe = simplexml_load_string($xml);
24$nsl = $sxe->getNamespaces();
25var_dump($nsl);
26
27$sxe = simplexml_load_string($xml, NULL, 0, $nsl['soap']);
28var_dump($sxe->Body);
29var_dump($sxe->Body->children(''));
30var_dump($sxe->Body->children('')->businessList);
31
32?>
33--EXPECTF--
34array(1) {
35  ["soap"]=>
36  string(41) "http://schemas.xmlsoap.org/soap/envelope/"
37}
38object(SimpleXMLElement)#%s (0) {
39}
40object(SimpleXMLElement)#%s (1) {
41  ["businessList"]=>
42  object(SimpleXMLElement)#%s (2) {
43    ["@attributes"]=>
44    array(1) {
45      ["foo"]=>
46      string(3) "bar"
47    }
48    ["businessInfo"]=>
49    object(SimpleXMLElement)#%s (1) {
50      ["@attributes"]=>
51      array(1) {
52        ["businessKey"]=>
53        string(3) "bla"
54      }
55    }
56  }
57}
58object(SimpleXMLElement)#%s (2) {
59  ["@attributes"]=>
60  array(1) {
61    ["foo"]=>
62    string(3) "bar"
63  }
64  ["businessInfo"]=>
65  object(SimpleXMLElement)#%s (1) {
66    ["@attributes"]=>
67    array(1) {
68      ["businessKey"]=>
69      string(3) "bla"
70    }
71  }
72}
73