xref: /PHP-7.2/ext/simplexml/tests/bug45553.phpt (revision f1d7e3ca)
1--TEST--
2Bug #45553 (Using XPath to return values for attributes with a namespace does not work)
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7$xml =<<<XML
8<xml xmlns:a="http://a">
9    <data a:label="I am A" label="I am Nothing">test1</data>
10    <a:data a:label="I am a:A" label="I am a:Nothing">test2</a:data>
11</xml>
12XML;
13
14$x = simplexml_load_string($xml);
15$x->registerXPathNamespace("a", "http://a");
16
17$atts = $x->xpath("/xml/data/@a:label");
18echo $atts[0] . "\n";
19$atts = $x->xpath("/xml/a:data");
20echo $atts[0]->attributes() . "\n";
21$atts = $x->xpath("/xml/a:data/@a:label");
22echo $atts[0] . "\n";
23$atts = $x->xpath("/xml/a:data/@label");
24echo $atts[0] . "\n";
25$atts = $x->xpath("/xml/data/@label");
26echo $atts[0] . "\n";
27?>
28===DONE===
29--EXPECTF--
30I am A
31I am a:Nothing
32I am a:A
33I am a:Nothing
34I am Nothing
35===DONE===
36
37