Fast specialized XML trade parser
Branch: master
Clone or download
Konstantin Nazarov
Konstantin Nazarov Port to newer luajit
Latest commit c168556 Oct 1, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake Update FindTarantool.cmake to not override local directories. Jul 27, 2017
tradeparser Port to newer luajit Oct 1, 2018
.gitignore Initial parser version May 5, 2017
CMakeLists.txt Rename xmlparser to tradeparser May 12, 2017
README.md
assault.py Script to upload generated xml documents May 19, 2017
gen.py Add counterparty generator May 23, 2017
test.lua Rename xmlparser to tradeparser May 12, 2017
tradeparser-scm-1.rockspec Add rockspec May 18, 2017

README.md

Fast specialized XML trade parser

This parser consumes equity trades in a proprietory format and turns them into Lua dictionaries. The primary feature of this parser is speed. It can do 200 MB/sec on a single CPU core.

Example input:

<root>
    <value1>
        <Type>Integer</Type>
        <Value>1</Value>
    </value1>
    <value2>
        <Type>Double</Type>
        <Value>1.2345</Value>
    </value2>
    <value3>
        <Type>Boolean</Type>
        <Value>true</Value>
    </value3>
    <value4>
        <Type>String</Type>
        <Value>Строка в UTF-8</Value>
    </value4>
    <value5>
        <Type>DateTime</Type>
        <Value>2017-03-05T00:00:00+03:00</Value>
    </value5>
    <a_list>
      <item>foo</item>
      <item>bar</item>
      <item>qux</item>
    </a_list>
</root>

Example output:

{
  "root": {
    "value1": 1,
    "value2": 1.2345,
    "value3": true,
    "value4": "Строка в UTF-8",
    "value5": 1488661200,
    "a_list": [
      "foo",
      "bar",
      "qux"
    ]
  }
}

Usage

local parser = require('tradeparser')
local json = require('json')

local xmltext = io.open("example.xml", "r"):read("*a")

local root = parser.parse(xmltext)
print(json.encode(root))