Tag Archives: XML

xml_get_error_code()

It returns XML parser error code

Example

<?php

$xmlparser = xml_parser_create();

$fp = fopen(‘test.xml’, ‘r’);

while ($xmldata = fread($fp, 4096)){

 if (!xml_parse($xmlparser,$xmldata,feof($fp)))

echo xml_error_string(xml_get_error_code($xmlparser));

}

xml_parser_free($xmlparser);

?>

Share

xml_get_current_line_number()

It returns current  line number for an XML parser

Example

<?php

$xmlparser = xml_parser_create();

$fp = fopen(‘test.xml’, ‘r’);

while ($xmldata = fread($fp, 4096)){

 if (!xml_parse($xmlparser,$xmldata,feof($fp)))

echo xml_get_current_line_number($xmlparser);

}

xml_parser_free($xmlparser);

?>

Share

xml_get_current_column_number()

It returns current column number for an XML parser

Example

<?php

$xmlparser = xml_parser_create();

$fp = fopen(‘test.xml’, ‘r’);

while ($xmldata = fread($fp, 4096)){

 if (!xml_parse($xmlparser,$xmldata,feof($fp)))

echo xml_get_current_column_number($xmlparser);

}

xml_parser_free($xmlparser);

?>

Share

xml_get_current_byte_index()

It returns current byte index for an XML parser

Example

<?php

$xmlparser = xml_parser_create();

$fp = fopen(‘test.xml’, ‘r’);

while ($xmldata = fread($fp, 4096)){

 if (!xml_parse($xmlparser,$xmldata,feof($fp)))

echo xml_get_current_byte_index($xmlparser);

}

xml_parser_free($xmlparser);

?>

Share

xml_error_string()

It returns an error string from the XML parser

Example

<?php

$xmlparser = xml_parser_create();

$fp = fopen(‘test.xml’, ‘r’);

while ($xmldata = fread($fp, 4096)){

 if (!xml_parse($xmlparser,$xmldata,feof($fp)))

echo xml_error_string(xml_get_error_code($xmlparser));

}

print_r($xmldata);

xml_parser_free($xmlparser);

?>

Share

XML Parser functions

Share

LibXML functions

Share