RE: [PHP] XML + PHP is going to eat my shorts

From: Date: Wed, 17 Nov 2004 05:59:16 +0000
Subject: RE: [PHP] XML + PHP is going to eat my shorts
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-202274@lists.php.net to get a copy of this message
On Tue, 2004-11-16 at 08:51 -0600, Jay Blanchard wrote: > [snip] > > <?xml version="1.0" encoding="ISO-8859-1"?> > > > > ... it throws an error from xml_get_error_code > > Trim your xml file. Whitespace can cause this problem. > [/snip] > > I trimmed and chopped to no avail. Argh. Try this snippet which has worked for me in the past. If you can email me the xml file in question, I can run it through my parser directly. Anyway, hope this helps: while ($data = fread($fp, 4096)){ $data=eregi_replace(">"."[[:space:]]+"."<","><",$data); if (!xml_parse($xmlparser, $data, feof($fp))) { $reason = xml_error_string(xml_get_error_code($xmlparser)); $reason .= xml_get_current_line_number($xmlparser); die($reason); } } --

« previous php.general (#202274) next »