PHP libxml error code 68 htmlParseEntityRef: no name



I am using the PHP libxml library to process xml files. As part of this process I set libxml_use_internal_errors(true), I load the xml from the file and check for any xml errors using libxml_get_errors().


Here is my code:



$filename = $local_dir . $file;
$file_parts = pathinfo($filename);

if ( $file_parts['extension'] != 'xml' ) continue;

$xml_string = file_get_contents($filename);

// check for valid xml
libxml_use_internal_errors(true);

$doc = new DOMDocument('1.0', 'utf-8');

$doc->loadXML( $xml_string );

$xml_errors = libxml_get_errors();

if (!empty($xml_errors) ) {
echo 'There is an error in file: ' . $file . '<br>';
print_r($xml_errors);
libxml_clear_errors();
continue;
}


This code is part of a loop that processes multiple xml files, the $filename variable is being set correctly.


On my local Wamp server no errors are returned but when I run this on a development server I get the following error for some xml files:


LibXMLError Object (

[level] => 2

[code] => 68

[column] => 202

[message] => htmlParseEntityRef: no name

[file] =>

[line] => 1

)


Can anyone explain what this error means?


Thanks

Anthony Lavin


No comments:

Post a Comment