blob: 5ac0d62d31abcedb13fadd875b2383d4c81e62ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
class xml_stream_callback_parser extends xml_stream_parser {
function __construct($stream) {
$this->cdata = "";
$this->tags = array();
$this->attrs = array();
parent::__construct($stream);
}
function cdata($parser, $cdata) {
$this->cdata .= $cdata;
}
function tag_open($parser, $tag, $attributes) {
array_push($this->tags, $tag);
array_push($this->attrs, $attributes);
}
function tag_close($parser, $tag) {
$attributes = array_pop($this->attrs);
for ($tags = $this->tags; count($tags); array_shift($tags)) {
$method = "handle_".join("_", $tags);
if (method_exists($this, $method)) {
$this->$method($attributes);
break;
}
}
$this->cdata = "";
array_pop($this->tags);
}
}
?>
|