ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
XML2DOM Class Reference
+ Collaboration diagram for XML2DOM:

Public Member Functions

 __construct ($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 85 of file class.ilXML2DOM.php.

Constructor & Destructor Documentation

◆ __construct()

XML2DOM::__construct (   $a_xml)

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

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

Member Function Documentation

◆ characterData()

XML2DOM::characterData (   $a_parser,
  $a_data 
)

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

138 {
139 $a_data = preg_replace("/&/", "&", $a_data);
140
141 $GLOBALS["lastObj"]->setContent($a_data);
142 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

References $GLOBALS.

◆ clean()

XML2DOM::clean ( $attr)

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

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

Referenced by startElement().

+ Here is the caller graph for this function:

◆ endElement()

XML2DOM::endElement (   $a_parser,
  $a_name 
)

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

133 {
134 $GLOBALS["lastObj"]->setParent();
135 }

References $GLOBALS.

◆ insertNode()

XML2DOM::insertNode ( $dom,
$node 
)

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

145 {
146 $node = $this->xmlStruct->insert($dom, $node);
147 }

◆ startElement()

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

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

120 {
121 if (!is_object($this->xmlStruct)) {
122 #vd($a_attrs);
123 $this->xmlStruct = new XMLStruct($a_name, $a_attrs);
124 $GLOBALS["lastObj"] = &$this->xmlStruct;
125 } else {
126 $a_attrs = $this->clean($a_attrs);
127 #var_dump("<pre>",++$counter," ",$a_name," -> ",$a_attrs,"<pre>");
128 $GLOBALS["lastObj"]->append($a_name, $a_attrs);
129 }
130 }
clean(&$attr)
Class for creating an object (new node) by parsing XML code and adding it to an existing DOM object.

References $GLOBALS, and clean().

+ Here is the call graph for this function:

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