summaryrefslogtreecommitdiff
path: root/xml.class
diff options
context:
space:
mode:
Diffstat (limited to 'xml.class')
-rw-r--r--xml.class15
1 files changed, 10 insertions, 5 deletions
diff --git a/xml.class b/xml.class
index a315d3e..f61793f 100644
--- a/xml.class
+++ b/xml.class
@@ -119,10 +119,15 @@ function flatten($with_attr = false)
return $result;
}
+# Strip namespace and convert extra characters to _
+function _make_identifier($name)
+{
+ return preg_replace(array('/^.*:/', '/\W/'), array('', '_'), $name);
+}
+
function start_element($parser, $name, $attrs)
{
- $name = strtr($name, "-", "_");
- $name = preg_replace('/^.*:/', '', $name);
+ $name = it_xml::_make_identifier($name);
$name = $this->_p['prefix'] . $name;
if (!class_exists($name))
@@ -139,14 +144,14 @@ function start_element($parser, $name, $attrs)
if ($attrs)
{
foreach ($attrs as $key => $val)
- $this->_stack[0]->attr[preg_replace('/^.*:/', '', $key)] = $val;
+ $this->_stack[0]->attr[it_xml::_make_identifier($key)] = $val;
}
}
function end_element($parser, $name)
{
- $name = preg_replace('/^.*:/', '', $name);
- $name = strtr($name, "-", "_");
+ $name = it_xml::_make_identifier($name);
+
if (!$this->_stack[0]->consume($this->_p))
{
if (is_array($this->_stack[1]->$name))