ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
XMLStruct Class Reference

Class for creating an object (new node) by parsing XML code and adding it to an existing DOM object. More...

+ Collaboration diagram for XMLStruct:

Public Member Functions

 __construct ($a_name="", $a_attrs=array())
 constructor More...
 
 append ($a_name, $a_attrs)
 append node More...
 
 setParent ()
 set parent node More...
 
 setContent ($a_data)
 set content text More...
 
 insert (&$dom, &$node)
 insert new node in existing DOM object More...
 

Data Fields

 $childs = array()
 
 $parent
 
 $name
 
 $content = array()
 
 $attrs
 

Detailed Description

Class for creating an object (new node) by parsing XML code and adding it to an existing DOM object.

Author
Jens Conze jconz.nosp@m.e@da.nosp@m.tabay.nosp@m..de
Version
$Id$

Definition at line 13 of file class.ilXML2DOM.php.

Constructor & Destructor Documentation

◆ __construct()

XMLStruct::__construct (   $a_name = "",
  $a_attrs = array() 
)

constructor

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

25  {
26  $this->name = $a_name;
27  $this->attrs = $a_attrs;
28  }

Member Function Documentation

◆ append()

XMLStruct::append (   $a_name,
  $a_attrs 
)

append node

Definition at line 33 of file class.ilXML2DOM.php.

References $GLOBALS.

34  {
35  $struct = new XMLStruct($a_name, $a_attrs);
36  $struct->parent =& $GLOBALS["lastObj"];
37 
38  $GLOBALS["lastObj"] =& $struct;
39  $this->childs[] =& $struct;
40  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Class for creating an object (new node) by parsing XML code and adding it to an existing DOM object...

◆ insert()

XMLStruct::insert ( $dom,
$node 
)

insert new node in existing DOM object

Parameters
object$domDOM object
object$nodeparent node

Definition at line 64 of file class.ilXML2DOM.php.

65  {
66  $newNode = $dom->create_element($this->name);
67  if ($this->content != "")
68  {
69  $newNode->set_content(implode("", $this->content));
70  }
71  if (is_array($this->attrs))
72  {
73  #vd($this->attrs);
74  reset ($this->attrs);
75  while (list ($key, $val) = each ($this->attrs)) {
76  $newNode->set_attribute($key, $val);
77  }
78  }
79  $node = $node->append_child($newNode);
80  for ($j = 0; $j < count($this->childs); $j++)
81  {
82  $this->childs[$j]->insert($dom, $node);
83  }
84  $node = $node->parent_node();
85  }

◆ setContent()

XMLStruct::setContent (   $a_data)

set content text

Definition at line 53 of file class.ilXML2DOM.php.

54  {
55 //echo "<br>XMLStruct:setContent-".$this->name."-$a_data-";
56  $this->content[] = $a_data;
57  }

◆ setParent()

XMLStruct::setParent ( )

set parent node

Definition at line 45 of file class.ilXML2DOM.php.

References $GLOBALS.

46  {
47  $GLOBALS["lastObj"] =& $GLOBALS["lastObj"]->parent;
48  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

Field Documentation

◆ $attrs

XMLStruct::$attrs

Definition at line 19 of file class.ilXML2DOM.php.

◆ $childs

XMLStruct::$childs = array()

Definition at line 15 of file class.ilXML2DOM.php.

◆ $content

XMLStruct::$content = array()

Definition at line 18 of file class.ilXML2DOM.php.

◆ $name

XMLStruct::$name

Definition at line 17 of file class.ilXML2DOM.php.

◆ $parent

XMLStruct::$parent

Definition at line 16 of file class.ilXML2DOM.php.


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