XML_2_TXT Extractor

Documentation

Overview

A lightweight tool for converting structured XML data into TXT files using a flexible configuration file.

The program reads an XML file and generates one or more TXT files according to rules defined in config.ini.

The configuration file must be located in the same directory as the executable and saved in UTF-8 encoding.

Features

How it works

Each section in config.ini generates one TXT output file.

[BusStops_Station]

Produces:

BusStops_Station.txt

The converter reads XML elements and formats them into TXT rows based on configuration rules.

General settings

[General]
output_location = 1

Determines where the output folder is created.

Value Description
0 output folder next to input XML
1 output folder next to executable

Standard processing

Standard mode means:

1 XML item = 1 output row

[BusStops_Station]

section = BusStops
item = BusStop
key = Station
fields = ID,"NameFull (ZoneID)","NameFull (ZoneID)"

Parameters

Parameter Meaning
section XML container element
item repeating XML element
key text before "=" in output
fields output template

Example output:

Station=123,"Main Street (1)","Main Street (1)"

Fields syntax

Fields are separated by commas.

Syntax Meaning
ID XML attribute or element value
"text" constant text
empty empty column
field@Item reference to another XML element

Examples:

fields = ID
fields = ID,"NameFull"
fields = ID,"NameFull (ID)"
fields = SuperID@Zone,,ID@Zone

Nested XML access

If elements are deeper in the XML hierarchy, use the parent parameter.

parent = Tariffs/Tariff/PriceTable/Data

Table grouping

XML may contain multiple tables inside one structure. Use group and separator.

group = PriceTable

separator =
ID@Tariffs/Tariff,
Name@Tariffs/Tariff,
Payment@Tariffs/Tariff/PriceTable

Example output:

1,City Tariff,Cash,QR
Price=1,21.00,60
Price=2,25.00,90

MERGE processing

Merge mode combines multiple XML records into one output row.

[Zones_MainZone]

type = merge

section = Zones
item = Zone

key = MainZone
fields = SuperID@Zone,,ID@Zone;"Name@SuperZone"

group_by = SuperID
value = ID

Example output:

MainZone=10,,101,102,103;"Central"

Running the program

  1. Select an XML file
  2. The program loads config.ini
  3. TXT files are generated in the output directory

Possibly future improvements