<?php
class XMLParser_ORIGIN
{
// raw xml
var $rawXML;
// xml parser
var $parser = null;
// array returned by the xml parser
var $valueArray = array();
var $keyArray = array();
// arrays for dealing with duplicate keys
var $duplicateKeys = array();
// return data
var $output = array();
var $status;
function XMLParser_ORIGIN($xml){
$this->rawXML = $xml;
$this->parser = xml_parser_create();
return $this->parse();
}
function parse(){
$parser = $this->parser;
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); // Dont mess with my cAsE sEtTings
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); // Dont bother with empty info
if(!xml_parse_into_struct($parser, $this->rawXML, $this->valueArray, $this->keyArray)){
$this->status = 'error: '.xml_error_string(xml_get_error_code($parser)).' at line '.xml_get_current_line_number($parser);
return false;
}
xml_parser_free($parser);
$this->findDuplicateKeys();
// tmp array used for stacking
$stack = array();
$increment = 0;
foreach($this->valueArray as $val) {
if($val['type'] == "open") {
//if array key is duplicate then send in increment
if(array_key_exists($val['tag'], $this->duplicateKeys)){
array_push($stack, $this->duplicateKeys[$val['tag']]);
$this->duplicateKeys[$val['tag']]++;
}
else{
// else send in tag
array_push($stack, $val['tag']);
}
} elseif($val['type'] == "close") {
array_pop($stack);
// reset the increment if they tag does not exists in the stack
if(array_key_exists($val['tag'], $stack)){
$this->duplicateKeys[$val['tag']] = 0;
}
} elseif($val['type'] == "complete") {
//if array key is duplicate then send in increment
if(array_key_exists($val['tag'], $this->duplicateKeys)){
array_push($stack, $this->duplicateKeys[$val['tag']]);
$this->duplicateKeys[$val['tag']]++;
}
else{
// else send in tag
array_push($stack, $val['tag']);
}
$this->setArrayValue($this->output, $stack, $val['value']);
array_pop($stack);
}
$increment++;
}
$this->status = 'success';
return true;
}
function findDuplicateKeys(){
for($i=0;$i < count($this->valueArray); $i++) {
// duplicate keys are when two complete tags are side by side
if($this->valueArray[$i]['type'] == "complete"){
if( $i+1 < count($this->valueArray) ){
if($this->valueArray[$i+1]['tag'] == $this->valueArray[$i]['tag'] && $this->valueArray[$i+1]['type'] == "complete"){
$this->duplicateKeys[$this->valueArray[$i]['tag']] = 0;
}
}
}
// also when a close tag is before an open tag and the tags are the same
if($this->valueArray[$i]['type'] == "close"){
if( $i+1 < count($this->valueArray) ){
if( $this->valueArray[$i+1]['type'] == "open" && $this->valueArray[$i+1]['tag'] == $this->valueArray[$i]['tag'])
$this->duplicateKeys[$this->valueArray[$i]['tag']] = 0;
}
}
}
}
function setArrayValue(&$array, $stack, $value){
if ($stack) {
$key = array_shift($stack);
$this->setArrayValue($array[$key], $stack, $value);
return $array;
} else {
$array = $value;
}
}
function getOutput(){
return $this->output;
}
function getStatus(){
return $this->status;
}
}
?>| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| Smarty/ | 2013-11-12 21:07 | 343.97 KB | 76129f60960:kunden | dxwrx-rx-r | |
| billsafe_2/ | 2013-11-12 21:07 | 21.38 KB | 76129f60960:kunden | dxwrx-rx-r | |
| afterbuy.php | 2013-11-12 21:06 | 31.51 KB | 76129f60960:kunden | -xw-x----- | |
| banktransfer_validation.php | 2013-11-12 21:06 | 82.12 KB | 76129f60960:kunden | -xw-x----- | |
| boxes.php | 2013-11-12 21:06 | 8.36 KB | 76129f60960:kunden | -xw-x----- | |
| boxes_old.php | 2013-11-12 21:06 | 366 B | 76129f60960:kunden | -xw-x----- | |
| breadcrumb.php | 2013-11-12 21:06 | 2.02 KB | 76129f60960:kunden | -xw-x----- | |
| cc_validation.php | 2013-11-12 21:06 | 3.42 KB | 76129f60960:kunden | -xw-x----- | |
| class.heidelpay.php | 2013-11-12 21:06 | 25.39 KB | 76129f60960:kunden | -xw-x----- | |
| class.inputfilter.php | 2013-11-12 21:06 | 13.32 KB | 76129f60960:kunden | -xw-x----- | |
| class.moneybookers.php | 2013-11-12 21:06 | 12.02 KB | 76129f60960:kunden | -xw-x----- | |
| class.phpmailer.php | 2013-11-12 21:06 | 46.01 KB | 76129f60960:kunden | -xw-x----- | |
| class.smtp.php | 2013-11-12 21:06 | 33.77 KB | 76129f60960:kunden | -xw-x----- | |
| http_client.php | 2013-11-12 21:06 | 13.32 KB | 76129f60960:kunden | -xw-x----- | |
| language.php | 2013-11-12 21:06 | 6.31 KB | 76129f60960:kunden | -xw-x----- | |
| main.php | 2013-11-12 21:06 | 5.58 KB | 76129f60960:kunden | -xw-x----- | |
| message_stack.php | 2013-11-12 21:06 | 3.29 KB | 76129f60960:kunden | -xw-x----- | |
| navigation_history.php | 2013-11-12 21:06 | 4.71 KB | 76129f60960:kunden | -xw-x----- | |
| order.php | 2013-11-12 21:06 | 29.55 KB | 76129f60960:kunden | -xw-x----- | |
| order_total.php | 2013-11-12 21:06 | 11.43 KB | 76129f60960:kunden | -xw-x----- | |
| payment.php | 2013-11-12 21:06 | 13.57 KB | 76129f60960:kunden | -xw-x----- | |
| paypal_checkout.php | 2013-11-12 21:06 | 72.2 KB | 76129f60960:kunden | -xw-x----- | |
| phpmailer.lang-de.php | 2013-11-12 21:06 | 1.21 KB | 76129f60960:kunden | -xw-x----- | |
| phpmailer.lang-en.php | 2013-11-12 21:06 | 1.04 KB | 76129f60960:kunden | -xw-x----- | |
| product.php | 2013-11-12 21:06 | 25.61 KB | 76129f60960:kunden | -xw-x----- | |
| sessions.php | 2013-11-12 21:06 | 13.23 KB | 76129f60960:kunden | -xw-x----- | |
| shipping.php | 2013-11-12 21:06 | 5.95 KB | 76129f60960:kunden | -xw-x----- | |
| shopping_cart.php | 2013-11-12 21:06 | 26.02 KB | 76129f60960:kunden | -xw-x----- | |
| split_page_results.php | 2013-11-12 21:06 | 8.15 KB | 76129f60960:kunden | -xw-x----- | |
| vat_validation.php | 2013-11-12 21:06 | 30.28 KB | 76129f60960:kunden | -xw-x----- | |
| wish_list.php | 2013-11-12 21:06 | 20.18 KB | 76129f60960:kunden | -xw-x----- | |
| xmlparserv4.php | 2013-11-12 21:06 | 4.24 KB | 76129f60960:kunden | -xw-x----- | |
| xtbooster.php | 2013-11-12 21:06 | 2.8 KB | 76129f60960:kunden | -xw-x----- | |
| xtcPrice.php | 2013-11-12 21:06 | 20.16 KB | 76129f60960:kunden | -xw-x----- | |