tags:

views:

80

answers:

4

I have an XML file that is written by a PHP script. The data for the XML file is gathered from several different RSS feeds. The PHP script is invoked every 5 minutes by a Cron Job. The PHP Script takes maybe 5-10 seconds to write the XML File.

Here's the problem: After the XML file is written, I can open it through DreamWeaver and read everything just fine - but when I enter the XML File's URL into my Web Browser (IE or Firefox), I get a "XML Parsing Error: not well-formed" Error in the Browser. When I do View > Source in the Browser, the XML file appears incomplete - but when I open the file directly off the server, it is complete.

Anyone know what's going on here?

A: 

Well, it could be that the XML is in a different encoding to the one the web server specifies in the headers. That could mess things up.

I suggest you use Wireshark to see whether the data is actually being delivered correctly. Also look at the XML document itself and its content encoding, versus the one the web server specifies.

What happens if you do a "Save As... " from the browser and try to open the result? That may well ignore the content encoding specified in the headers, and just dump the file to disk - if I'm right, it should then open correctly in an XML editor.

Jon Skeet
A: 

Hello, It could help to have the copy/paste of the xml file.

I suspect that Dreamweaver accepts as an xml file something that is not really xml (a problem with an entity or with an xml-reserved character) or that you have an encoding problem. Do you have character outside the ASCII 127 character set ?

Jerome Wagner

Jerome WAGNER
A: 

Its a long shot, but you could check if you're setting an invalid "Content-Length" header. This would cause a browser to partially download a file.

Bob Fanger
A: 

The answer ended up dealing with the encoding from the originating RSS feeds. The originating feeds were encoded using ISO-8859-1, and this needed to be converted to UTF-8 before writing the data to my XML file.

//Get Data from source URL
$xml = file_get_contents("http://www.sourceurl.com/someting.rss");
//Convert from ISO to UTF
$xml = mb_convert_encoding($xml, 'UTF-8', mb_detect_encoding($xml, 'UTF-8, ISO-8859-1', true)); 

Once this was done, I can traverse through $xml however I need and write the data to my personalized XML file. Apparently there are some charactersin the ISO-8895-1 encoding that were not being interpreted correctly before being written to my XML file.

Chris