parser error : Detected an entity reference loop
While importing a rather large XML-document (45MB+) into a database today, I ran into a weird problem on one specific server. The server runs SUSE Enterprise and presented an error that neither other test server gave. After a bit of digging around on the web I were able to collect enough information from several different threads about what could be the source of the problem.
It seems that the limit was introduced in libxml2 about half a year ago to avoid some other memory problems, but this apparently borked quite a few legitimate uses. As I have very little experience with administrating SUSE Enterprise based servers, I quickly shrugged off trying to update the packages and possibly recompiling PHP. Luckily one of the comments in a thread about the problem saved the day.
If you find yourself running into this message; swap your named entities in the XML file (such as < and >) to numeric entities (such as < and >). This way libxml2 just replaces everything with the byte value while parsing instead of trying to be smart and keep an updated cache.
Tags: libxml, libxml2, parsing, PHP, Programming, redhat, rhn, xml

July 23rd, 2009 at 22:59
Thanks a lot for the tip – I just ran into the same issue with libxml2 on OSX.
September 2nd, 2009 at 01:44
Thanks a lot! i had the same problem from php on debian etch, but the numeric entities tip did the trick!
thanks again