xref: /PHP-7.0/ext/simplexml/tests/profile13.phpt (revision 610c7fbe)
1--TEST--
2SimpleXML [profile]: Accessing by namespace prefix
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
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);
24var_dump($sxe->children('soap', 1));
25
26$sxe = simplexml_load_string($xml, NULL, 0, 'soap', 1);
27var_dump($sxe->Body);
28var_dump($sxe->Body->children(''));
29var_dump($sxe->Body->children('')->businessList);
30
31?>
32===DONE===
33<?php exit(0); ?>
34--EXPECTF--
35object(SimpleXMLElement)#%d (1) {
36  ["Body"]=>
37  object(SimpleXMLElement)#%d (0) {
38  }
39}
40object(SimpleXMLElement)#%d (0) {
41}
42object(SimpleXMLElement)#%d (1) {
43  ["businessList"]=>
44  object(SimpleXMLElement)#%d (2) {
45    ["@attributes"]=>
46    array(1) {
47      ["foo"]=>
48      string(3) "bar"
49    }
50    ["businessInfo"]=>
51    object(SimpleXMLElement)#%d (1) {
52      ["@attributes"]=>
53      array(1) {
54        ["businessKey"]=>
55        string(3) "bla"
56      }
57    }
58  }
59}
60object(SimpleXMLElement)#%d (2) {
61  ["@attributes"]=>
62  array(1) {
63    ["foo"]=>
64    string(3) "bar"
65  }
66  ["businessInfo"]=>
67  object(SimpleXMLElement)#%d (1) {
68    ["@attributes"]=>
69    array(1) {
70      ["businessKey"]=>
71      string(3) "bla"
72    }
73  }
74}
75===DONE===
76