xref: /php-src/ext/simplexml/tests/bug45553.phpt (revision 7f2f0c00)
1--TEST--
2Bug #45553 (Using XPath to return values for attributes with a namespace does not work)
3--EXTENSIONS--
4simplexml
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--EXPECT--
29I am A
30I am a:Nothing
31I am a:A
32I am a:Nothing
33I am Nothing
34
35