a memo

Enhanced XML Parsing In PHP

It seems that our parser is choking on certain HTML entities, like ö -- what to do? Update: This is technically a problem with improper CDATA quoting in newsfeeds. But it isn't going to go away.

First of all, here's a function from the PEAR XML parser (http://pear.php.net/package-info.php?pacid=19) that could help...
$xml = preg_replace(array("/\&([a-z\d\#]+)\;/i",
"/\&/",
"/\#\|\|([a-z\d\#]+)\|\|\#/i",
"/(\=\"\-\/\%\?\!\'\(\)\[\\{\}\ \#\+\,\@_])/e"
),
array("#||\\1||#",
"&",
"&\\1;",
"'&#'.ord('\\1').';'"
),
$xml
);

By Chris Snyder on January 31, 2003 at 8:22pm

jump to top