©2006-2017 IAAI Software

Contact Us Privacy Policy

Format String Specification

A Magic Parser format string describes the base file type (XML or CSV) and other data representation parameters required by the parser. Providing a format string in the optional 3rd parameter to the main MagicParser_parse() function improves performance by skipping the autodetection process. Format string values contain a number of parameters separated by the pipe ("|") character.

XML Format

Parameter Description
1 - Base Type "xml" (without the quotes)
2 - Repeating Element XPath The XPath expression of the element within the document that repeats for each record. For example, the repeating element XPath for an RSS feed is "RSS/CHANNEL/ITEM/" (without the quotes)

CSV Format

Parameter Description
1 - Base Type "csv" (without the quotes)
2 - Field Separator ASCII character code of the field separator. Common values include 44 (comma), 9 (tab), 124 (pipe) and 59 (semi-colon). Can be any character code in the range 0-255.
3 - Header Row? 0 (no) or 1 (yes)
4 - Text Delimiter ASCII character code of the text delimiter. Common values include 34 (double quote) and 39 (single quote). Can be any character code in the range 1-255. 0 indicates no text delimitation.

Examples

xml|PRODUCTS/PRODUCT/ XML file, records enclosed by <products><product> ... </product></products>
csv|44|0|0 CSV file, comma separated values, no header row
csv|9|1|0 CSV file, tab separated values, header row