DOM 2 util.  
 More...
| 
Static Public Member Functions | 
| static | changeName ($node, $name, $keep_attributes=true) | 
|  | Change name of a node. 
 | 
| static | addParent ($node, $name) | 
|  | Add parent. 
 | 
| static | replaceByChilds ($node) | 
|  | Replace a node by its child. 
 | 
Detailed Description
DOM 2 util. 
- Author
- Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e 
- Version
- $Id$ / 
Definition at line 11 of file class.ilDOM2Util.php.
Member Function Documentation
  
  | 
        
          | static ilDOM2Util::addParent | ( |  | $node, |  
          |  |  |  | $name |  
          |  | ) |  |  |  | static | 
 
Add parent. 
- Parameters
- 
  
  
- Returns
Definition at line 47 of file class.ilDOM2Util.php.
Referenced by ilPCParagraph\handleAjaxContent().
        {
                $newnode = $node->ownerDocument->createElement($name);
                $par = $node->parentNode;
                if ($next_sib = $node->nextSibling)
                {
                        $newnode = $par->insertBefore($newnode, $next_sib);
                }
                else
                {
                        $newnode = $par->appendChild($newnode);
                }
                
                $node = $par->removeChild($node);
                $newnode->appendChild($node);
                
                return $newnode;
        }
 
 
  
  | 
        
          | static ilDOM2Util::changeName | ( |  | $node, |  
          |  |  |  | $name, |  
          |  |  |  | $keep_attributes = true |  
          |  | ) |  |  |  | static | 
 
Change name of a node. 
- Parameters
- 
  
    | object | $node |  |  |  | string | new name |  
 
- Returns
Definition at line 20 of file class.ilDOM2Util.php.
Referenced by ilPCParagraph\handleAjaxContent().
        {
                $newnode = $node->ownerDocument->createElement($name);
                foreach ($node->childNodes as $child)
                {
                        $child2 = $child->cloneNode(true);
                        $newnode->appendChild($child2);
                }
                if ($keep_attributes)
                {
                        foreach ($node->attributes as $attrName => $attrNode)
                        {
                                $newnode->setAttribute($attrName, $attrNode);
                        }
                }
                $node->parentNode->replaceChild($newnode, $node);
                return $newnode;
        }
 
 
  
  | 
        
          | static ilDOM2Util::replaceByChilds | ( |  | $node | ) |  |  | static | 
 
Replace a node by its child. 
- Parameters
- 
  
  
- Returns
Definition at line 82 of file class.ilDOM2Util.php.
Referenced by ilPCParagraph\handleAjaxContent().
        {
                foreach ($node->childNodes as $child)
                {
                        $child2 = $child->cloneNode(true);
                        $node->parentNode->insertBefore($child2, $node);
                }
                $node->parentNode->removeChild($node);
        }
 
 
The documentation for this class was generated from the following file: