To detect that concatenation of data is taking place, you can keep track of whether the last function call was to the data processing function.
e.g. using $this->inside_data variable below:
<?php
xml_set_element_handler($this->parser, "start_tag", "end_tag");
xml_set_character_data_handler($this->parser, "contents");
protected function contents($parser, $data)
{
switch ($this->current_tag) {
case "name":
if ($this->inside_data)
$this->name .= $data; else
$this->name = $data;
break;
...
}
$this->inside_data = true;
}
protected function start_tag($parser, $name)
{
$this->current_tag = $name;
$this->inside_data = false;
}
protected function end_tag() {
$this->current_tag = '';
$this->inside_data = false;
}
?>