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