1--TEST-- 2Test xml_set_processing_instruction_handler function : basic 3--SKIPIF-- 4<?php 5if (!extension_loaded("xml")) { 6 print "skip - XML extension not loaded"; 7} 8?> 9--FILE-- 10<?php 11/* Prototype : proto bool xml_set_processing_instruction_handler ( resource $parser , callback $handler ) 12 * Description: Sets the processing instruction (PI) handler function for the XML parser. 13 * Source code: ext/xml/xml.c 14 * Alias to functions: 15 */ 16 17class XML_Parser 18{ 19 20 function PIHandler($parser, $target, $data) 21 { 22 echo "Target: " . $target. "\n"; 23 echo "Data: " . $data . "\n"; 24 } 25 26 function parse($data) 27 { 28 $parser = xml_parser_create(); 29 xml_set_object($parser, $this); 30 xml_set_processing_instruction_handler($parser, "PIHandler"); 31 xml_parse($parser, $data, true); 32 xml_parser_free($parser); 33 } 34 35 36} 37 38$xml = <<<HERE 39<?xml version="1.0" encoding="ISO-8859-1"?> 40<?xml-stylesheet href="default.xsl" type="text/xml"?> 41HERE; 42 43echo "Simple test of xml_set_processing_instruction_handler() function\n"; 44$p1 = new Xml_Parser(); 45$p1->parse($xml); 46echo "Done\n"; 47?> 48--EXPECT-- 49Simple test of xml_set_processing_instruction_handler() function 50Target: xml-stylesheet 51Data: href="default.xsl" type="text/xml" 52Done