ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
XML2DOM Class Reference
+ Collaboration diagram for XML2DOM:

Public Member Functions

 XML2DOM ($a_xml)
 
 clean (&$attr)
 
 startElement ($a_parser, $a_name, $a_attrs)
 
 endElement ($a_parser, $a_name)
 
 characterData ($a_parser, $a_data)
 
 insertNode (&$dom, &$node)
 

Detailed Description

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

Member Function Documentation

◆ characterData()

XML2DOM::characterData (   $a_parser,
  $a_data 
)

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

References $GLOBALS.

146  {
147  $a_data = preg_replace("/&/","&",$a_data);
148 
149  $GLOBALS["lastObj"]->setContent($a_data);
150  }
$GLOBALS['ct_recipient']

◆ clean()

XML2DOM::clean ( $attr)

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

109  {
110  if(is_array($attr))
111  {
112  foreach($attr as $key => $value)
113  {
114  $attr[$key] = preg_replace("/&(?!amp;|lt;|gt;|quot;)/","&",$attr[$key]);
115  $attr[$key] = preg_replace("/\"/",""",$attr[$key]);
116  $attr[$key] = preg_replace("/</","&lt;",$attr[$key]);
117  $attr[$key] = preg_replace("/>/","&gt;",$attr[$key]);
118  }
119  }
120  return $attr;
121  }

◆ endElement()

XML2DOM::endElement (   $a_parser,
  $a_name 
)

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

References $GLOBALS.

141  {
142  $GLOBALS["lastObj"]->setParent();
143  }
$GLOBALS['ct_recipient']

◆ insertNode()

XML2DOM::insertNode ( $dom,
$node 
)

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

153  {
154  $node = $this->xmlStruct->insert($dom, $node);
155  }

◆ startElement()

XML2DOM::startElement (   $a_parser,
  $a_name,
  $a_attrs 
)

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

References $GLOBALS, and XMLStruct\XMLStruct().

125  {
126  if (!is_object($this->xmlStruct))
127  {
128  #vd($a_attrs);
129  $this->xmlStruct = new XMLStruct($a_name, $a_attrs);
130  $GLOBALS["lastObj"] =& $this->xmlStruct;
131  }
132  else
133  {
134  $a_attrs = $this->clean($a_attrs);
135  #var_dump("<pre>",++$counter," ",$a_name," -> ",$a_attrs,"<pre>");
136  $GLOBALS["lastObj"]->append($a_name, $a_attrs);
137  }
138  }
clean(&$attr)
$GLOBALS['ct_recipient']
Class for creating an object (new node) by parsing XML code and adding it to an existing DOM object...
+ Here is the call graph for this function:

◆ XML2DOM()

XML2DOM::XML2DOM (   $a_xml)

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

92  {
93  $xml_parser = xml_parser_create("UTF-8");
94  xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
95  xml_set_object($xml_parser, $this);
96  xml_set_element_handler($xml_parser, "startElement", "endElement");
97  xml_set_character_data_handler($xml_parser, "characterData");
98 
99  if (!xml_parse($xml_parser, $a_xml, true))
100  {
101  die(sprintf("XML error: %s at line %d",
102  xml_error_string(xml_get_error_code($xml_parser)),
103  xml_get_current_line_number($xml_parser)));
104  }
105  xml_parser_free($xml_parser);
106  }

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