ILIAS  release_8 Revision v8.24
ilDOM2Util Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilDOM2Util:

Static Public Member Functions

static changeName (DOMNode $node, string $name, bool $keep_attributes=true)
 
static addParent (DOMNode $node, string $name)
 
static replaceByChilds (DOMNode $node)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning DOM 2 util

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 24 of file class.ilDOM2Util.php.

Member Function Documentation

◆ addParent()

static ilDOM2Util::addParent ( DOMNode  $node,
string  $name 
)
static

Definition at line 49 of file class.ilDOM2Util.php.

52 : DOMNode {
53 $newnode = $node->ownerDocument->createElement($name);
54 $par = $node->parentNode;
55 if ($next_sib = $node->nextSibling) {
56 $newnode = $par->insertBefore($newnode, $next_sib);
57 } else {
58 $newnode = $par->appendChild($newnode);
59 }
60
61 $node = $par->removeChild($node);
62 $newnode->appendChild($node);
63 return $newnode;
64 }
if($format !==null) $name
Definition: metadata.php:247

◆ changeName()

static ilDOM2Util::changeName ( DOMNode  $node,
string  $name,
bool  $keep_attributes = true 
)
static

Definition at line 27 of file class.ilDOM2Util.php.

31 : DOMNode {
32 $newnode = $node->ownerDocument->createElement($name);
33
34 foreach ($node->childNodes as $child) {
35 $child2 = $child->cloneNode(true);
36 $newnode->appendChild($child2);
37 }
38 if ($keep_attributes) {
39 foreach ($node->attributes as $attrName => $attrNode) {
40 $newnode->setAttribute($attrName, $attrNode);
41 }
42 }
43 $node->parentNode->replaceChild($newnode, $node);
44
45 return $newnode;
46 }

◆ replaceByChilds()

static ilDOM2Util::replaceByChilds ( DOMNode  $node)
static

Definition at line 67 of file class.ilDOM2Util.php.

67 : void
68 {
69 foreach ($node->childNodes as $child) {
70 $child2 = $child->cloneNode(true);
71 $node->parentNode->insertBefore($child2, $node);
72 }
73 $node->parentNode->removeChild($node);
74 }

The documentation for this class was generated from the following file: