26        $this->name = $a_name;
 
   27        $this->attrs = $a_attrs;
 
   33    public function append($a_name, $a_attrs)
 
   35        $struct = 
new XMLStruct($a_name, $a_attrs);
 
   36        $struct->parent =&
$GLOBALS[
"lastObj"];
 
   39        $this->childs[] =&$struct;
 
   56        $this->content[] = $a_data;
 
   64    public function insert(&$dom, &$node)
 
   66        $newNode = $dom->create_element($this->name);
 
   67        if ($this->content != 
"") {
 
   68            $newNode->set_content(implode(
"", $this->content));
 
   70        if (is_array($this->attrs)) {
 
   73            while (list(
$key, $val) = each($this->attrs)) {
 
   74                $newNode->set_attribute(
$key, $val);
 
   77        $node = $node->append_child($newNode);
 
   78        for ($j = 0; $j < count($this->childs); $j++) {
 
   79            $this->childs[$j]->insert($dom, $node);
 
   81        $node = $node->parent_node();
 
   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");
 
   95        if (!xml_parse($xml_parser, $a_xml, 
true)) {
 
   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)
 
  102        xml_parser_free($xml_parser);
 
  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(
"/</", 
"<", $attr[
$key]);
 
  112                $attr[
$key] = preg_replace(
"/>/", 
">", $attr[
$key]);
 
  121        if (!is_object($this->xmlStruct)) {
 
  123            $this->xmlStruct = 
new XMLStruct($a_name, $a_attrs);
 
  124            $GLOBALS[
"lastObj"] =&$this->xmlStruct;
 
  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);
 
  139        $a_data = preg_replace(
"/&/", 
"&", $a_data);
 
  141        $GLOBALS[
"lastObj"]->setContent($a_data);
 
  146        $node = $this->xmlStruct->insert($dom, $node);
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
insertNode(&$dom, &$node)
endElement($a_parser, $a_name)
characterData($a_parser, $a_data)
startElement($a_parser, $a_name, $a_attrs)
Class for creating an object (new node) by parsing XML code and adding it to an existing DOM object.
append($a_name, $a_attrs)
append node
insert(&$dom, &$node)
insert new node in existing DOM object
setParent()
set parent node
__construct($a_name="", $a_attrs=array())
constructor
setContent($a_data)
set content text
$GLOBALS['loaded']
Global hash that tracks already loaded includes.