Parsing a Processing Instruction
<?php
function pi_handler ($p, $target, $data) {
print ($target);
print ($data);
}
$xml = "<?exec ls -l /var?><rootElement/>";
$p = xml_parser_create ();
xml_set_processing_instruction_handler ($p, 'pi_handler');
if (!xml_parse ($p, $xml, true))
die (sprintf ("Parse error in <code>%s</code> (%s)",
htmlspecialchars ($xml),
xml_error_string (xml_get_error_code ($p))));
else
print ("XML processing complete.\n");
xml_parser_free ($p);
?>
Related examples in the same category