xref: /php-src/ext/simplexml/tests/profile13.phpt (revision 7f2f0c00)
1--TEST--
2SimpleXML [profile]: Accessing by namespace prefix
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);
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--EXPECTF--
33object(SimpleXMLElement)#%d (1) {
34  ["Body"]=>
35  object(SimpleXMLElement)#%d (0) {
36  }
37}
38object(SimpleXMLElement)#%d (0) {
39}
40object(SimpleXMLElement)#%d (1) {
41  ["businessList"]=>
42  object(SimpleXMLElement)#%d (2) {
43    ["@attributes"]=>
44    array(1) {
45      ["foo"]=>
46      string(3) "bar"
47    }
48    ["businessInfo"]=>
49    object(SimpleXMLElement)#%d (1) {
50      ["@attributes"]=>
51      array(1) {
52        ["businessKey"]=>
53        string(3) "bla"
54      }
55    }
56  }
57}
58object(SimpleXMLElement)#%d (2) {
59  ["@attributes"]=>
60  array(1) {
61    ["foo"]=>
62    string(3) "bar"
63  }
64  ["businessInfo"]=>
65  object(SimpleXMLElement)#%d (1) {
66    ["@attributes"]=>
67    array(1) {
68      ["businessKey"]=>
69      string(3) "bla"
70    }
71  }
72}
73