summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gaffney <agaffney@gentoo.org>2006-04-15 20:12:05 +0000
committerAndrew Gaffney <agaffney@gentoo.org>2006-04-15 20:12:05 +0000
commit9660b9c9a59cccf4e30f199036fd8198423db487 (patch)
treea15809f5c4357fe4e24a5718941f9a6c9f192e5d /webgli/XMLParser.php
parentmissing ; (diff)
downloadscire-9660b9c9a59cccf4e30f199036fd8198423db487.tar.gz
scire-9660b9c9a59cccf4e30f199036fd8198423db487.tar.bz2
scire-9660b9c9a59cccf4e30f199036fd8198423db487.zip
working versions of XMLParser and webgliIP
svn path=/; revision=17
Diffstat (limited to 'webgli/XMLParser.php')
-rw-r--r--webgli/XMLParser.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/webgli/XMLParser.php b/webgli/XMLParser.php
index 842fda1..4ebe13e 100644
--- a/webgli/XMLParser.php
+++ b/webgli/XMLParser.php
@@ -3,7 +3,6 @@
class XMLParser {
function start_handler($parser, $name, $attr) {
-# if(substr($this->xmlpath, 0, 1) == "/") $this->xmlpath = substr($this->xmlpath, 1);
$tmpxmlpath = $this->xmlpath ? explode("/", $this->xmlpath) : array();
$tmpxmlpath[] = $name;
$this->xmlpath = implode("/", $tmpxmlpath);
@@ -11,12 +10,26 @@ class XMLParser {
}
function end_handler($parser, $name) {
-# $this->chardata = preg_replace('/(^\s+|\s+$)/', '', $this->chardata);
if($this->xmlpaths[$this->xmlpath]) {
if($this->values[$this->xmlpaths[$this->xmlpath]]) {
- $this->set($this->xmlpaths[$this->xmlpath], trim($this->chardata));
+ $this->chardata = trim($this->chardata);
+ switch($this->values[$this->xmlpaths[$this->xmlpath]]['type']) {
+ case 'string':
+ case 'uri':
+ break;
+ case 'bool':
+ $this->chardata = $this->chardata == "True" ? 1 : 0;
+ break;
+ case 'int':
+ $this->chardata = intval($this->chardata);
+ break;
+ case 'array':
+ $this->chardata = explode(" ", $this->chardata);
+ if(count($this->chardata) == 1 && !$this->chardata[0]) $this->chardata = array();
+ break;
+ }
+ $this->set($this->xmlpaths[$this->xmlpath], $this->chardata);
} else {
- # Let's ignore this for now
call_user_func(array($this, $this->xmlpaths[$this->xmlpath]), trim($this->chardata), array_pop($this->attrs));
}
} else {