is there any reason why I should be struggling to parse something as simple as an omg editorial
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
print_r($record);
}
$result = MagicParser_parse("http://creatives.omg2.com/xml/240.xml","myRecordHandler");
if (!$result)
{
print MagicParser_getErrorMessage();
}
?>
all I can get is Array ( [FIELD1] => ÿþ ) Array ( [FIELD1] => )
can you advise where I am going wrong?
many thanks for your help and really quick responce.
Is there any reason why the “ symbols are being displayed as ?
This can happen when the character encoding of the feed you are parsing does not match the character encoding of the PHP page that you are generating.
The way to test this is to select an alternative character set from your browser's "View -> Encoding" menu and see if the ?'s are converted into the correct characters. After that, it is a case of changing the HTTP header in your PHP script to set the required encoding. For example if your feed turns out to be ISO-8859-1 encoded but your PHP installation is creating a UTF-8 page by default you can add the following code to the top of your script:
header("Content-Type: text/html;charset=ISO-8859-1");
Hope this helps..!
Hi,
As the source file has only a single record the autodetection will probably not work; so I would specify the actual format string required for this feed, which can be seen on this demo page (will be deleted shortly).
This would make your source code required:
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
print_r($record);
}
$result = MagicParser_parse("http://creatives.omg2.com/xml/240.xml","myRecordHandler","xml|ROOT/");
if (!$result)
{
print MagicParser_getErrorMessage();
}
?>
Hope this helps...