readXML($url); <- Reads XML url // $xml->writeXML($file); <- Writes current XML structure to file // $xml->printXML(); <- Print current XML // // $xml->nodes; <- RootNode // $xml->nodes->addSubNode($node); <- Add subnode // $node->getSubNodeIterator(); <- get a iterator to move through all subnodes /* xmlV4 callbacks because PHP 4.0 is lame. (using Array($this,'function') doesnt call the instance $this)*/ function xmlV4_readXMLTagStart($parser,$name,$attribs) { $GLOBALS['activeXMLReader']->readXMLTagStart($parser,$name,$attribs); } function xmlV4_readXMLTagEnd($parser,$name) { $GLOBALS['activeXMLReader']->readXMLTagEnd($parser,$name); } function xmlV4_readXMLCharacterData($parser,$data) { $GLOBALS['activeXMLReader']->readXMLCharacterData($parser,$data); } function xmlV4_readXMLDefault($parser,$data) { $GLOBALS['activeXMLReader']->readXMLDefault($parser,$data); } class xmlV4 { var $file; var $url; var $parser; var $nodes; var $currentNode; var $parseError; function __construct() { $this->nodes = new xmlNode(""); $this->nodes->isRoot = true; $this->currentNode =& $this->nodes; $this->i=0; } function readXML($url) { $this->parser = xml_parser_create(); if ( !$this->parser ) return false; $GLOBALS['activeXMLReader'] =& $this; if ( !xml_parser_set_option($this->parser,XML_OPTION_CASE_FOLDING,0) ) return false; if ( !xml_parser_set_option($this->parser,XML_OPTION_SKIP_WHITE,0) ) return false; if ( !xml_set_element_handler($this->parser,"xmlV4_readXMLTagStart","xmlV4_readXMLTagEnd") ) return false; if ( !xml_set_character_data_handler($this->parser, "xmlV4_readXMLCharacterData") ) return false; if ( !xml_set_default_handler($this->parser,"xmlV4_readXMLDefault") ) return false; $this->url = $url; if (!($this->file = fopen($url, "r"))) { $parseError = "Failed to open URL: $url"; return false; } while ($data = fread($this->file, 4096)) { if (!xml_parse($this->parser, $data, feof($this->file))) { $parseError = sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser)); return false; } } xml_parser_free($this->parser); return true; } function writeXML($file) { $f = fopen($file,"w"); if ( !$f ) return false; fwrite($f,$this->nodes->create()); fclose($f); return true; } function printXML($isRSS = false,$includeHeaders=false) { if ( $includeHeaders ) { header("Content-type: text/xml"); } $this->nodes->isRSS = $isRSS; // print as RSS (this adds the RSS tag if it doesnt exist) print($this->nodes->create()); } function readXMLDefault($parser,$data) { //echo "readXMLDefault: $data
"; } function readXMLCharacterData($parser,$data) { $this->currentNode->addContent(html_entity_decode(html_entity_decode($data))); } function readXMLTagStart($parser,$name,$attribs) { $subNode = new xmlNode($name); $subNode->attributes = $attribs; $this->currentNode->addSubNode($subNode); $this->currentNode =& $subNode; } function readXMLTagEnd($parser,$name) { $this->currentNode =& $this->currentNode->parent; } } class xmlNodeIterator { var $nodes; var $current; var $i; function __construct(&$nodeList) { $this->current = 0; $this->i = -1; $this->nodes =& $nodeList; } function moveNext() { $this->i++; if ( isset($this->nodes[$this->i]) ) { $this->current =& $this->nodes[$this->i]; return true; } return false; } } class xmlNode { var $tag; var $value; var $attributes; var $subNodes; var $parent; var $isRoot; var $isRSS; function __construct($name,$value='') { $this->isRoot = false; $this->isRSS = false; $this->tag = $name; $this->value = $value; $this->attributes = array(); $this->subNodes = array(); $this->parent = null; $this->nodeId = rand(1, 9999999); } function &getSubNodeIterator() { $ref = new xmlNodeIterator($this->subNodes); return $ref; } function addContent($data) { $this->value .= $data; } function addSubNode($node) { $node->parent =& $this; array_push($this->subNodes,&$node); } function hasSubNodes() { if ( count($this->subNodes) > 0 ) return true; return false; } public function getAttribute($key) { if(!isset($this->attributes[$key])) return false; return $this->attributes[$key]; } public function getAttributes() { return $this->attributes; } public function setAttribute($key, $val) { $this->attributes[$key] = $val; } // Returns a multidimensional array tags will be the keynames // NOTE : duplicate names will be merged function createSubNodeArray() { $subArray = array(); $it =& $this->getSubNodeIterator(); while($it->moveNext()) { if ( $it->current->hasSubNodes() ) $subArray[$it->current->tag] = $it->current->createSubNodeArray(); else $subArray[$it->current->tag] = $it->current->value; } return $subArray; } function create() { if ( $this->isRoot ) { $element = ''; $tagList = array(); foreach($this->subNodes AS $object) { $element .= $object->create(); array_push($tagList, $object->tag); } if ( $this->isRSS && !in_array("rss",$tagList) ) $element = '' . $element . ''; if ( !in_array("?xml",$tagList) ) $element = '' . "\n" . $element; return $element; } $element = "<".$this->tag; foreach($this->attributes AS $key=>$value) { $element .= ' ' . $key . '="'. htmlspecialchars($value) . '"'; } $content = ''; foreach($this->subNodes AS $object) { $content .= $object->create(); } if ( empty($this->value) || preg_match("{^[A-Za-z0-9_ \.]*$}",$this->value) ) $content .= $this->value; else $content .= 'value) . ']]>'; if ( $content != '' ) $element .= '>'.$content.'tag.'>' . "\n"; else $element .= ' />' . "\n"; return $element; } } ?>
Fatal error: Class 'xmlV4' not found in /var/www/nl.dendaspelletjes/public/core/cache/includes/elements/modsnippet/38.include.cache.php on line 16