| @@ 367-392 (lines=26) @@ | ||
| 364 | * <p>DOMElement a new instance of class DOMElement or false |
|
| 365 | * if an error occured.</p> |
|
| 366 | */ |
|
| 367 | protected function changeElementName(\DOMNode $node, string $name) |
|
| 368 | { |
|
| 369 | $ownerDocument = $node->ownerDocument; |
|
| 370 | if (!$ownerDocument) { |
|
| 371 | return false; |
|
| 372 | } |
|
| 373 | ||
| 374 | $newNode = $ownerDocument->createElement($name); |
|
| 375 | ||
| 376 | foreach ($node->childNodes as $child) { |
|
| 377 | $child = $ownerDocument->importNode($child, true); |
|
| 378 | $newNode->appendChild($child); |
|
| 379 | } |
|
| 380 | ||
| 381 | foreach ($node->attributes ?? [] as $attrName => $attrNode) { |
|
| 382 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 383 | $newNode->setAttribute($attrName, $attrNode); |
|
| 384 | } |
|
| 385 | ||
| 386 | if ($newNode->ownerDocument) { |
|
| 387 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 388 | $newNode->ownerDocument->replaceChild($newNode, $node); |
|
| 389 | } |
|
| 390 | ||
| 391 | return $newNode; |
|
| 392 | } |
|
| 393 | ||
| 394 | /** |
|
| 395 | * Returns children of node. |
|
| @@ 336-361 (lines=26) @@ | ||
| 333 | * <p>DOMElement a new instance of class DOMElement or false |
|
| 334 | * if an error occured.</p> |
|
| 335 | */ |
|
| 336 | protected function changeElementName(\DOMNode $node, string $name) |
|
| 337 | { |
|
| 338 | $ownerDocument = $node->ownerDocument; |
|
| 339 | if (!$ownerDocument) { |
|
| 340 | return false; |
|
| 341 | } |
|
| 342 | ||
| 343 | $newNode = $ownerDocument->createElement($name); |
|
| 344 | ||
| 345 | foreach ($node->childNodes as $child) { |
|
| 346 | $child = $ownerDocument->importNode($child, true); |
|
| 347 | $newNode->appendChild($child); |
|
| 348 | } |
|
| 349 | ||
| 350 | foreach ($node->attributes ?? [] as $attrName => $attrNode) { |
|
| 351 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 352 | $newNode->setAttribute($attrName, $attrNode); |
|
| 353 | } |
|
| 354 | ||
| 355 | if ($newNode->ownerDocument) { |
|
| 356 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 357 | $newNode->ownerDocument->replaceChild($newNode, $node); |
|
| 358 | } |
|
| 359 | ||
| 360 | return $newNode; |
|
| 361 | } |
|
| 362 | ||
| 363 | /** |
|
| 364 | * Returns children of node. |
|