{ if (trim($data)) { println($data); } } function process_testpi($data) { printfln('Processing instruction testpi: %s', $data); } function unknown_endtag($name) { println('end: ' . $name); } function handle_comment($data) { println($data); } } $data = '<?xml version="1.0"?> <div> <p>test</p> <p>Some more <b>testing</b></p> <?testpi This is a processing instruction ?> <!-- This is a comment --> <p>Finally, some more testing.</p> Heh. </div>'; $p = new TestParser(); $p->feed($data); $p->close();