RE: XML + PHP is going to eat my shorts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
   }
}
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux