It returns array of errors
Example
<?php
libxml_get_errors()
?>
It returns array of errors
Example
<?php
libxml_get_errors()
?>
It disable the ability to load external entities
Example
<?php
libxml_disable_entity_loader()
?>
It clears the libxml error buffer
Example
<?php
libxml_clear_errors()
?>
Example
<?php
$xmlparser=xml_parser_create();
function char($xmlparser,$data) {
echo $data;
}
function unparsed_ent_handler_func($xmlparser,$entname,$base,$sysID,$pubID,$notname){
echo $entname.$sysID.$pubID.$notname.
}
xml_set_character_data_handler($xmlparser,”char”);
xml_set_unparsed_entity_decl_handler($xmlparser,”unparsed_ent_handler_func”);
$fp=fopen(“test.xml”,”r”);
while ($data=fread($fp,4096)) {
xml_parse($xmlparser,$data,feof($fp)) or die(“Failed”);
}
xml_parser_free($xmlparser);
?>
Example
<?php
$xmlparser=xml_parser_create();
function char($xmlparser,$data) {
echo $data;
}
function pi_handler_func($xmlparser, $target, $data) {
echo $target.$data;
}
xml_set_character_data_handler($xmlparser,”char”);
xml_set_processing_instruction_handler($xmlparser, “pi_handler_func”);
$fp=fopen(“book.xml”,”r”);
while ($data=fread($fp,4096)){
xml_parse($xmlparser,$data,feof($fp));
}
xml_parser_free($xmlparser);
?>
Example
<?php
class XMLParser{
var $xmlparser;
function XMLParser(){
$this->xmlparser = xml_parser_create();
xml_set_object($this->xmlparser, $this);
xml_set_character_data_handler($this->xmlparser,”char”);
xml_set_element_handler($this->xmlparser, “start_tag”,”end_tag”);
}
function parse($data){
xml_parse($this->xmlparser, $data);
}
function parse_File($xmlfile){
$fp = fopen($xmlfile, ‘r’);
while ($xmldata = fread($fp, 4096)){
if(!xml_parse($this->xmlparser, $xmldata)){
die(“Failed”);
}
}
}
function start_tag($xmlparser, $tag, $attributes){
print $tag . “n”;
}
function end_tag(){}
function char($xmlparser,$data){
echo $data . “n”;
}
function close_Parser(){
xml_parser_free($this->xmlparser);
}
}
$myxmlparser = new XMLParser();
$myxmlparser->parse_File(“book.xml”);
$myxmlparser->close_parser();
?>
Example
<?php
$parser=xml_parser_create();
function char($parser,$data){
echo $data;
}
function not_decl_func($parser,$not,$base,$sysID,$pubID) {
echo $not.$sysID.$pubID;
}
xml_set_character_data_handler($parser,”char”);
xml_set_notation_decl_handler($parser, “not_decl_func”);
$fp=fopen(“test.xml”,”r”);
while ($data=fread($fp,4096)) {
xml_parse($parser,$data,feof($fp)) or die(“Failed”);
}
xml_parser_free($parser);
?>
Example
<?php
$xmlparser=xml_parser_create();
function char($xmlparser,$data){
echo $data;
}
function ext_func($xmlparser,$ent,$base,$sysID,$pubID) {
echo $ent.”<br />”;
echo $sysID.”<br />”;
echo $pubID.”<BR />”;
}
xml_set_character_data_handler($xmlparser,”char”);
xml_set_external_entity_ref_handler($xmlparser, “ext_func”);
$fp=fopen(“book.xml”,”r”);
while ($data=fread($fp,4096))
{
xml_parse($xmlparser,$data,feof($fp)) or die(“Failed”);
}
xml_parser_free($xmlparser);
?>