xref: /PHP-8.4/ext/dom/tests/bug47531_b.phpt (revision f9a24969)
1--TEST--
2Bug #47531 (No way of removing redundant xmlns: declarations)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$doc = new DOMDocument;
9$doc->loadXML(<<<XML
10<container xmlns:foo="some:ns">
11    <foo:first/>
12    <foo:second xmlns:foo="some:ns2">
13        <foo:child1/>
14        <foo:child2/>
15        <!-- comment -->
16        <child3>
17            <foo:child4/>
18            <foo:child5 xmlns:foo="some:ns3">
19                <p xmlns:foo="other:ns">
20                    <span foo:foo="bar"/>
21                    <span foo:foo="bar"/>
22                </p>
23                <foo:child6 foo:foo="bar">
24                    <span foo:foo="bar"/>
25                    <span foo:foo="bar"/>
26                </foo:child6>
27            </foo:child5>
28        </child3>
29        <child7 xmlns:foo="some:ns" foo:foo="bar">
30            <foo:child8/>
31        </child7>
32    </foo:second>
33</container>
34XML);
35$root = $doc->documentElement;
36$elem = $root->firstElementChild->nextElementSibling;
37var_dump($elem->removeAttribute("xmlns:foo"));
38echo $doc->saveXML();
39
40?>
41--EXPECT--
42bool(true)
43<?xml version="1.0"?>
44<container xmlns:foo="some:ns">
45    <foo:first/>
46    <foo:second xmlns:foo="some:ns2">
47        <foo:child1/>
48        <foo:child2/>
49        <!-- comment -->
50        <child3>
51            <foo:child4/>
52            <foo:child5 xmlns:foo="some:ns3">
53                <p xmlns:foo="other:ns">
54                    <span foo:foo="bar"/>
55                    <span foo:foo="bar"/>
56                </p>
57                <foo:child6 foo:foo="bar">
58                    <span foo:foo="bar"/>
59                    <span foo:foo="bar"/>
60                </foo:child6>
61            </foo:child5>
62        </child3>
63        <child7 xmlns:foo="some:ns" foo:foo="bar">
64            <foo:child8/>
65        </child7>
66    </foo:second>
67</container>
68