{"id":13496034,"url":"https://github.com/manoelcampos/xml2lua","last_synced_at":"2025-04-05T12:09:09.250Z","repository":{"id":2558337,"uuid":"42945205","full_name":"manoelcampos/xml2lua","owner":"manoelcampos","description":"XML Parser written entirely in Lua that works for Lua 5.1+. Convert XML to and from Lua Tables 🌖💱","archived":false,"fork":false,"pushed_at":"2024-05-07T13:58:25.000Z","size":250,"stargazers_count":309,"open_issues_count":15,"forks_count":76,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T11:11:32.846Z","etag":null,"topics":["dtv","ginga","ginga-ncl","isdb","isdb-t","isdb-tb","lua","lua5","parser","sbtvd","xml","xml-parser","xml2lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manoelcampos.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-22T16:10:45.000Z","updated_at":"2025-02-24T17:36:38.000Z","dependencies_parsed_at":"2024-05-07T14:50:02.331Z","dependency_job_id":null,"html_url":"https://github.com/manoelcampos/xml2lua","commit_stats":{"total_commits":137,"total_committers":12,"mean_commits":"11.416666666666666","dds":"0.12408759124087587","last_synced_commit":"7e36b2ecad91841ef41f1be29902ef769807e91d"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoelcampos%2Fxml2lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoelcampos%2Fxml2lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoelcampos%2Fxml2lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manoelcampos%2Fxml2lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manoelcampos","download_url":"https://codeload.github.com/manoelcampos/xml2lua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332612,"owners_count":20921853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dtv","ginga","ginga-ncl","isdb","isdb-t","isdb-tb","lua","lua5","parser","sbtvd","xml","xml-parser","xml2lua"],"created_at":"2024-07-31T19:01:41.083Z","updated_at":"2025-04-05T12:09:09.226Z","avatar_url":"https://github.com/manoelcampos.png","language":"Lua","readme":":source-highlighter: highlightjs\n:numbered:\n:unsafe:\n\n= xml2lua image:https://img.shields.io/github/actions/workflow/status/manoelcampos/xml2lua/build.yml[GitHub Actions Workflow Status] image:http://img.shields.io/badge/license-MIT-brightgreen.svg[MIT license,link=http://opensource.org/licenses/MIT] image:https://img.shields.io/luarocks/v/manoelcampos/xml2lua[LuaRocks,link=https://luarocks.org/modules/manoelcampos/xml2lua]\n\npass:[\u003ca href=\"https://buymeacoff.ee/manoelcampos\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: 30px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;\" \u003e\u003c/a\u003e]\n\nifdef::env-github[]\n:outfilesuffix: .adoc\n:caution-caption: :fire:\n:important-caption: :exclamation:\n:note-caption: :paperclip:\n:tip-caption: :bulb:\n:warning-caption: :warning:\nendif::[]\n\nimage:conversion-ways.png[]\n\n*xml2lua* is an XML parser written entirely in Lua which doesn't depend on any external C/C++ library.\nIt works for Lua 5.1 to 5.3 and enables:\n\n* parsing an XML string into a Lua Table;\n* converting a Lua Table to an XML string.\n\nThis version was adapted to work with Lua 5 and can be used in Lua applications, including\ninteractive Digital Television (DTV) http://gingancl.org.br/en[Ginga NCL applications] for the http://www.dtv.org.br[Brazilian DTV System]\n(worldwide known as https://en.wikipedia.org/wiki/ISDB-T_International[ISDB-T International or ISDB-Tb]).\n\nThe original parser was written by Paul Chakravarti and is available on http://lua-users.org/wiki/LuaXml[LuaUsers].\n\n== Installation\n\n=== From LuaRocks repository\n\nThe best way to download the module is using\nhttps://luarocks.org/modules/manoelcampos/xml2lua[LuaRocks] at the command line:\n\n[source,bash]\n----\nluarocks install xml2lua\n----\n\n=== From local sources\n\nDownload the source files using the download button above or type at a terminal:\n\n[source,bash]\n----\ngit clone https://github.com/manoelcampos/xml2lua.git\n----\n\nFinally, enter the directory where the source files were downloaded and type:\n\n[source,bash]\n----\nluarocks make\n----\n\n== How to use\n\n=== Parsing an XML String into a Lua Table\n\nA simplified example which parses an XML directly from a string is presented below.\n*There are some caveats to deal with when an XML has just one tag.\nCheck the link:example1.lua[example1.lua] for details.*\n\n[source,lua]\n----\nlocal xml2lua = require(\"xml2lua\")\n--Uses a handler that converts the XML to a Lua table\nlocal handler = require(\"xmlhandler.tree\")\n\nlocal xml = [[\n\u003cpeople\u003e\n  \u003cperson type=\"natural\"\u003e\n    \u003cname\u003eManoel\u003c/name\u003e\n    \u003ccity\u003ePalmas-TO\u003c/city\u003e\n  \u003c/person\u003e\n  \u003cperson type=\"legal\"\u003e\n    \u003cname\u003eUniversity of Brasília\u003c/name\u003e\n    \u003ccity\u003eBrasília-DF\u003c/city\u003e\n  \u003c/person\u003e\n\u003c/people\u003e\n]]\n\n--Instantiates the XML parser\nlocal parser = xml2lua.parser(handler)\nparser:parse(xml)\n\n--Manually prints the table (since the XML structure for this example is previously known)\nfor i, p in pairs(handler.root.people.person) do\n  print(i, \"Name:\", p.name, \"City:\", p.city, \"Type:\", p._attr.type)\nend\n----\n\n=== Converting a Lua Table to an XML String\n\n[source,lua]\n----\nlocal xml2lua = require(\"xml2lua\")\nlocal people = {\n    person = {\n        {name=\"Manoel\", city=\"Palmas-TO\", _attr={ type='natural' } },\n        {name=\"Breno\", city=\"Palmas-TO\", _attr={ type='legal' } }\n    }\n}\n\nprint(\"People Table\\n\")\nxml2lua.printable(people)\n\nprint()\nprint(\"XML Representation\\n\")\nprint(xml2lua.toXml(people, \"people\"))\n----\n\n== Command line tool\n\nYou can use a command line tool to try parsing XML files.\nExecute `lua testxml.lua -help` on the terminal for more details.\n\n== Running tests\n\n=== Requirements\n\nYou must have https://docs.docker.com/compose/install/[installed docker and docker compose].\n\n=== How to\n\n[source,bash]\n----\nmake lint # to run the lint check\nmake test # to run the acceptance tests\n----\n\n== License\n\nThis code is freely distributable under the terms of the link:LICENSE[MIT license].\n\n== Authors\n\n* Manoel Campos da Silva Filho http://about.me/manoelcampos\n* Paul Chakravarti link:mailto:\u0026#112;a\u0026#117;\u0026#x6c;\u0026#x63;\u0026#x40;\u0026#x70;\u0026#97;\u0026#x73;\u0026#x73;t\u0026#104;\u0026#x65;\u0026#97;a\u0026#114;\u0026#100;\u0026#118;a\u0026#114;k\u0026#x2e;\u0026#99;\u0026#x6f;\u0026#x6d;[\u0026#112;a\u0026#117;\u0026#x6c;\u0026#x63;\u0026#x40;\u0026#x70;\u0026#97;\u0026#x73;\u0026#x73;t\u0026#104;\u0026#x65;\u0026#97;a\u0026#114;\u0026#100;\u0026#118;a\u0026#114;k\u0026#x2e;\u0026#99;\u0026#x6f;\u0026#x6d;]\n","funding_links":[],"categories":["Lua"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanoelcampos%2Fxml2lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanoelcampos%2Fxml2lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanoelcampos%2Fxml2lua/lists"}