|
---
libxml was created by XML pedants. It throws a FATAL error for any undefined entity.
Real data notes are created by XML ignoramuses (i.e., anybody but you and I).
They use entities that might not be defined. Browers cope by ignoring them.
php's XSLT is the short route from data to html, but it goes through the libxml choke point. What to do? After too much effort, I found the simple solution below.
function hideEntities($data) {
return str_replace("&", "&", $data);
}
// Sample use
$xmlfilename = "...";
$proc = new XSLTProcessor();
$xmldoc = new DOMDocument();
$xmldoc->substituteEntities = true; // collapse ampersands for HTML
$xml = hideEntities(file_get_contents($xmlfilename));
$xmldoc->loadXML($xml);
...
$proc->transformToXML($doc);
Sign up to add your own comment here!
|
|