You are here:  » Autodetection Limitations


Autodetection Limitations

The autodetection logic in Magic Parser is not foolproof, and there are a number of situations in which autodetection will either not work, or is not recommended. Autodetection may be overridden by providing a format string in the optional 3rd parameter to the MagicParser_parse() function.

General

Autodetection is not recommended when using Magic Parser with an Internet URL (when provided as the filename parameter). This is because PHP does not support the fseek() operation on file pointers opened using URL wrappers, and so the source file will be requested and transferred in full at least twice for every call to MagicParser_parse().

CSV Variant Autodetection

At least one popular affiliate network publishes CSV format product feeds using semi-colon separation. This format will incorrectly autodetect as comma separation. Semi-colon separation is still supported by using a format string similar to "csv|59|0|0" (depending upon header row presence and delimitation values).

XML Autodetection

The autodetection of the base file type as XML is robust as Magic Parser simply looks for the opening "<" character or standard XML declaration. However, detection of the repeating element can fail in documents with only a few records, and will almost always fail in single-record XML documents. Single-record XML documents may still be used with Magic Parser - you simply need to provide the top level element as the repeating element - for example "xml|INFO/" would be a valid format string if your XML document begins with the tag <info>.