xref: /PHP-5.3/ext/simplexml/tests/profile12.phpt (revision 610c7fbe)
1--TEST--
2SimpleXML [profile]: Accessing namespaced root and non namespaced children
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);
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===DONE===
34--EXPECTF--
35array(1) {
36  ["soap"]=>
37  string(41) "http://schemas.xmlsoap.org/soap/envelope/"
38}
39object(SimpleXMLElement)#%s (0) {
40}
41object(SimpleXMLElement)#%s (1) {
42  ["businessList"]=>
43  object(SimpleXMLElement)#%s (2) {
44    ["@attributes"]=>
45    array(1) {
46      ["foo"]=>
47      string(3) "bar"
48    }
49    ["businessInfo"]=>
50    object(SimpleXMLElement)#%s (1) {
51      ["@attributes"]=>
52      array(1) {
53        ["businessKey"]=>
54        string(3) "bla"
55      }
56    }
57  }
58}
59object(SimpleXMLElement)#%s (2) {
60  ["@attributes"]=>
61  array(1) {
62    ["foo"]=>
63    string(3) "bar"
64  }
65  ["businessInfo"]=>
66  object(SimpleXMLElement)#%s (1) {
67    ["@attributes"]=>
68    array(1) {
69      ["businessKey"]=>
70      string(3) "bla"
71    }
72  }
73}
74===DONE===
75