-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Description
Description
The following code:
$xml = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<test:root xmlns:test="http://example.com/dummy/ns">
<test:a/>
<test:b test:kind="123">abc</test:b>
</test:root>
EOF;
$d = \Dom\XMLDocument::createFromString($xml);
var_dump($d->C14N(true));Resulted in this output:
<test:root xmlns:test="http://example.com/dummy/ns" xmlns:xmlns="http://www.w3.org/2000/xmlns/" xmlns:test="http://example.com/dummy/ns">
<test:a></test:a>
<test:b test:kind="123">abc</test:b>
</test:root>
But I expected this output instead:
<test:root xmlns:test="http://example.com/dummy/ns">
<test:a></test:a>
<test:b test:kind="123">abc</test:b>
</test:root>
However, this code works:
$xml = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<test:root xmlns:test="http://example.com/dummy/ns">
<test:a/>
<test:b test:kind="123">abc</test:b>
</test:root>
EOF;
$d = new DOMDocument();
$d->loadXML($xml);
var_dump($d->C14N(true));Shouldn't the new \Dom\XMLDocument class give the same result as the "old" \DOMDocument class?
PHP Version
PHP 8.4.14 (cli) (built: Oct 24 2025 19:07:34) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.14, Copyright (c) Zend Technologies
with Zend OPcache v8.4.14, Copyright (c), by Zend Technologies
Operating System
Alpine Linux v3.22.2 (php:8.4-fpm-alpine docker image)