mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

You can break the hierarchy for attribute nodes, use the helper function
introduced recently [1] to fix this issue.
[1] 066d18f2
Closes GH-16377.
27 lines
521 B
PHP
27 lines
521 B
PHP
--TEST--
|
|
replaceChild with attribute children
|
|
--EXTENSIONS--
|
|
dom
|
|
--FILE--
|
|
<?php
|
|
|
|
$dom = new DOMDocument;
|
|
$attr = $dom->createAttribute('attr');
|
|
$attr->textContent = "test";
|
|
|
|
try {
|
|
$attr->replaceChild($dom->createProcessingInstruction('pi'), $attr->firstChild);
|
|
} catch (DOMException $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$root = $dom->appendChild($dom->createElement('root'));
|
|
$root->setAttributeNode($attr);
|
|
|
|
echo $dom->saveXML();
|
|
|
|
?>
|
|
--EXPECT--
|
|
Hierarchy Request Error
|
|
<?xml version="1.0"?>
|
|
<root attr="test"/>
|