xref: /PHP-7.4/ext/simplexml/tests/profile11.phpt (revision 40a3cdd9)
1--TEST--
2SimpleXML [profile]: Accessing two elements with the same name, but different namespaces
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7error_reporting(E_ALL & ~E_NOTICE);
8$root = simplexml_load_string('<?xml version="1.0"?>
9<root xmlns:reserved="reserved-ns" xmlns:special="special-ns">
10 <reserved:child>Hello</reserved:child>
11 <special:child>World</special:child>
12</root>
13');
14
15var_dump($root->children('reserved-ns')->child);
16var_dump($root->children('special-ns')->child);
17var_dump((string)$root->children('reserved-ns')->child);
18var_dump((string)$root->children('special-ns')->child);
19var_dump($root->child);
20?>
21===DONE===
22--EXPECTF--
23object(SimpleXMLElement)#%d (1) {
24  [0]=>
25  string(5) "Hello"
26}
27object(SimpleXMLElement)#%d (1) {
28  [0]=>
29  string(5) "World"
30}
31string(5) "Hello"
32string(5) "World"
33object(SimpleXMLElement)#%d (0) {
34}
35===DONE===
36