Giter Site home page Giter Site logo

lunarmodules / expadom Goto Github PK

View Code? Open in Web Editor NEW
2.0 5.0 4.0 128 KB

An XML DOM Level 2 Core implementation in Lua, based on the (Lua)Expat parser.

Home Page: https://lunarmodules.github.io/expadom/topics/01-Introduction.md.html

License: MIT License

Lua 97.50% CSS 2.50%
xml dom lua expat luaexpat

expadom's Introduction

expadom

Build Luacheck Coveralls code coverage SemVer License

An XML DOM Level 2 Core implementation in Lua, based on the (Lua)Expat parser.

Status

This library is under early development and does not have everything implemented yet. Scan the code for "TODO:" to see what is still to be done.

Synopsis

local DOM = require("expadom.DOMImplementation")()
local doc, root = DOM:createDocument(nil, "root")
root:appendChild(doc:createComment("let's create an address list"))
local list = doc:createElement("addresses")
list:setAttribute("country", "Netherlands")
root:appendChild(list)
local addr = doc:createElement("address")
list:appendChild(addr)
addr:appendChild(doc:createTextNode("address goes here"))

local xml_written = table.concat(doc:write())

-- result (formatting added for readability):
-- <?xml version="1.0" encoding="UTF-8"?>
-- <root>
--     <!--let's create an address list-->
--     <addresses country="Netherlands">
--         <address>address goes here</address>
--     </addresses>
-- </root>

-- now parse the document again:
local xml_parsed = require("expadom").parseDocument(xml_written)
local address = xml_parsed:getElementsByTagName("address")[1]
print(address.childNodes[1].nodeValue)  --> "address goes here"

Documentation

The documentation and reference is available in the /docs folder, and online.

Downloads, dependencies, and source code

Source code and downloads are available from the Github project page. Installation is typically easiest using LuaRocks.

Dependencies

Expadom depends on the following packages:

  • LuaExpat for parsing XML. This requires that libexpat itself is also installed.
  • The Lua module compat53 is required for UTF-8 support on Lua versions lacking the utf8 module (pre Lua 5.3).

When installing through LuaRocks, libexpat must be installed manually, the other dependencies will be dealt with by LuaRocks.

License & Copyright

The project is licensed under the MIT License

History

unreleased

  • Feat: return root element as well when creating a document (DOMimplementation) #5

22-Apr-2022 0.1.0 Initial release

  • Most of the DOM level 2 has been implemented

expadom's People

Contributors

alerque avatar tieske avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

expadom's Issues

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.