Coder Social home page Coder Social logo

manoelcampos / java-xml2lua Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 86 KB

Java Xml2Lua: command-line tool and library to convert XML to Lua format โ˜•๏ธ๐Ÿ“‘๐Ÿ’ฑ

Home Page: https://manoelcampos.com/JavaXml2Lua/

License: GNU General Public License v3.0

Lua 3.84% Java 93.49% Shell 2.67%
java xml lua converter xml2lua

java-xml2lua's Introduction

Java Xml2Lua Buy Me A Coffee

Build Status Maven Central Javadocs GPL licensed

The Java Xml2Lua allows parseing a XML file and converting it to Lua file, represented as a table, the native data structure of the Lua language.

It gets a XML file such as the following as input:

<products>
	<product id="12">
	  <description>TV 32''</description>
	  <brand>Samsung</brand>
	  <price>1200</price>
	</product>
	<product id="150">
	  <description>Netbook</description>
	  <brand>Asus</brand>
	  <price>900</price>
	</product>
</products>

Then, it converts it to a Lua file, representing the XML data as a Lua table:

products =  {
  [12]={
    description = "TV 32''", brand = "Samsung", price = "1200", 
  },
  [150]={
    description = "Netbook", brand = "Asus", price = "900", 
  },
  [198]={
    description = "Laser Printer", brand = "Samsung", price = "399", 
  },
}

Using it as a Maven dependency into your own project

The library can be added as a Maven dependency into your own project, by adding the following code to your pom.xml file:

<dependency>
    <groupId>com.manoelcampos</groupId>
    <artifactId>xml2lua</artifactId>
    <version>1.0.0</version>
</dependency>

Using the Xml2Lua class to convert a XML to a Lua file requires just few lines of code:

Xml2Lua parser = new Xml2Lua(xmlFilePath);
parser.convert();
System.out.printf("Lua file generated at %s.\n", parser.getLuaFileName());

Using it as a command line tool

You can use the available command tool to convert XML to Lua using the command line. If you downloaded the project source code, when you build it using mvn clean install or some IDE, a jar file will be created inside the target directory.

Alternatively, you can simply download the jar file from the releases page.

Once you have the jar file, you can run it as below:

java -jar xml2lua.jar XmlFilePath

The tool will generate a Lua file with the same name of the XML file, inside the directory of the XML file.

java-xml2lua's People

Contributors

manoelcampos avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.