xref: /php-src/ext/dom/tests/gh12455.phpt (revision 7d551a89)
1--TEST--
2GH-12455 (Namespace prefixes reused incorrectly depending on libxml2 version)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$doc = new DOMDocument();
9$element = $doc->createElementNS('http://test', 'a:x');
10$doc->appendChild($element);
11$element1 = $doc->createElementNS('http://test', 'b:y');
12$element->appendChild($element1);
13$element1->appendChild($doc->createElementNS('http://test', 'b:z'));
14echo $doc->saveXml();
15
16$xpath = new DOMXPath($doc);
17$xpath->registerNodeNamespaces = true;
18$xpath->registerNamespace('b', 'http://test');
19
20$elements = $xpath->query('//b:z');
21foreach ($elements as $e) {
22    var_dump($e->nodeName);
23}
24
25$elements = $xpath->query('//*[name()="b:z"]');
26echo $elements->length;
27
28?>
29--EXPECT--
30<?xml version="1.0"?>
31<a:x xmlns:a="http://test"><b:y xmlns:b="http://test"><b:z/></b:y></a:x>
32string(3) "b:z"
331
34