Code Notepad Software - Free Download Code Notepad - page 2 - Top 4 Download - Top4Download.com offers free software downloads for Windows, Mac, iOS and Android computers and mobile devices. Visit for free, full and secured software’s.
![Free download lua convert xml to table for mac os Free download lua convert xml to table for mac os](/uploads/1/2/6/2/126241751/419657604.gif)
|
The following is some sample code for handling XML. It is divided into four sections:
- toolkits;
- XML parsers which are Lua only;
- XML parsers which contain C code and a binding;
- modules for handling XML-based protocols such as XML-RPC and SOAP.
Credit to the authors is mentioned where appropriate.
Toolkits
LazyKit is a collection of XML processing tools. Its primary purpose is to provoke discussion of XML tools in Lua.
PenlightLibraries provides an XML module [See Docs] which uses the LOM defined by LuaExpat? and provides pretty-printing, template matching and Orbit-style 'htmlfication'. It will use LuaExpat? if available, otherwise falls back on a pure Lua parser based on Roberto's (see below).
Lua-only XML parsers
LuaBasicTagParser?
[LuaBasicTagParser] Works with lua 5.1 up to Lua 5.4xml2lua
[xml2lua] is an updated version that works for Lua 5.0 to 5.3. It was based on [LuaXML for Lua 4] by Paul Chakravarti.
The module implements a non-validating XML stream parser with a handler based event API (conceptually similar to SAX) which can be used to post-process the event data as required (eg into a tree).
The current functionality is -
- Tokenises well-formed XML (relatively robustly)
- Flexible handler based event api (
- Parses/generates events all XML elements - ie.
- Tags
- Text
- Comments
- CDATA
- XML Decl
- Processing Instructions
- DOCTYPE declarations
- Provides limited well-formedness checking (checks for basic syntax & balanced tags only)
- Flexible whitespace handling (selectable)
- Entity Handling (selectable)
The limitations are -
- Non-validating
- No charset handling
- No namespace support
- Shallow well-formedness checking only (fails to detect most semantic errors)
The distribution also includes sample event handlers to convert the SAX event stream into a Lua table -
- domHandler generates a DOM-like node tree structure and is capable of representing any valid XML document
- simpleTreeHandler attempts to generate a more 'natural' table based structure which supports many common XML formats and is generally more useful (there are some restrictions dealing with mixed content however)
SLAXML
Another pure-Lua non-validating SAX-like streaming processor. It also includes an implementation of a simple DOM parser (parse to hierarchy of tables).
Features:
- Pure Lua in a single file (two files if you use the DOM parser).
- Streaming parser does a single pass through the input and reports what it sees along the way.
- Supports elements, attributes, comments, text, CDATA, and processing instructions. (Does not support DTD or XML Declaration as a non-processing instruction).
- Supports namespaces
- Supports syntactically-valid XML such as
cond='7 > 5'
(but also incorrectly 'supports' certain invalid XML, such as<foo></bar>
or<a>5 < 7
) - Unescapes named XML entities (
< > & " '
) and numeric entities (e.g.
) in attributes and text nodes (but—properly—not in comments or CDATA). Properly handles edge cases like&amp;
. - Optionally ignore whitespace-only text nodes (as appear when indenting XML markup).
- Includes a DOM parser that is a both a convenient way to pull in XML to use as well as a nice example of using the streaming parser.
- Does not add any keys to the global namespace. Use the pattern
local SLAXML = require 'slaxml'
to use it.
Classic Lua-only version
From: Roberto Ierusalimschy
I have this basic skeleton that parses the 'main' part of an XML string (it does not handle meta-data like '
<?
' and '<!
'...). -- Roberto - [!] VersionNotice: The below code pertains to an older Lua version, Lua 4. It does not run as is under Lua 5.
- [!] This implementation apparently does not correctly parse colons (:), as used for XML namespaces. See below for a proposed fix.
Original version
From: Yutaka Ueno
That is my test program, which is now revised [1](link broken) But it is only tested for a few XML files used in biology. Probably Roberto's code provides a better skelton than mine, but there is a difference in xml-tag descriptions with Lua tables.
Because the property name 'xml' never appears in XML. This method is a bit better for terribly deep XML tags proposed in biology.
C bindings
Kino
From: Eckhart Koeppen
Well, there is something I programmed which might help, the Kino XML processor. It has wrappers for Tcl and Lua via SWIG. A Xt and an experimental Gtk widget for displaying XML with CSS are also available. Take a look at it at: [2](link broken)
It is under constant development but tries to stick to the DOM, so I hope that the interface changes remain small.
libxml
[luagnome] (link broken, use [3]) includes the wrapping of libxml-1.8.x, as it is considered as a part of Gnome. It allows to parse and to generate XML files, with a simple api (object oriented).
[lua-xmlreader] is an implementation of the
XmlReader
API using libxml2. Expat
For Lua 5.0/5.1, use [LuaExpat], which is full-featured.
For Lua 4.0:
From: Jay Carlson
I've put a simple binding of expat, James Clark's C stream-based XML parser up at [4]. No, not everything is bound, but it should be obvious how to bind more stuff to it.
LuaXML
[LuaXML] is a lean yet complete module for the direct mapping between XML data and Lua tables.
XML-DOM parser
PugXML is a C++ small, fast, non-validating DOM XML parser, contained in a single header, having no dependencies other than the standard C libraries, and <iostream> (KERNEL32.DLL with WIN32). This XML parser segments a given string in situ (like strtok), performing scanning/tokenization, and parsing in a single pass.
Here is an example of the parser use in Lua:
A wrapper around this parser has been written with [LuaBind] and is available at [5](link broken). The original article about PugXML is located at [6].
TinyXML
For Lua 5.0:
From: Robert Noll
Just a plain 'Parse File to lua array' function in c++, using the [TinyXML] (2.4.3) lib.
pugilua
a binding to the neat [pugixml], supporting DOM and XPath 1.0. The binding is made using [LuaBridge]Example:
xerceslua
As a supplement to pugilua there's an effort to provide a minimal binding to [xerces.apache.org/xerces-c/ Xerces-C++] to be able to validate xml documents:
assert(require 'xerceslua')
Example:
XML-based protocols
XML-RPC
For Lua 5.0/5.1, use [LuaXMLRPC] library developed by [The Kepler Project].
For Lua 4.0:
![Download Download](https://dl1.cbsistatic.com/i/2017/09/14/fa4f8f04-121a-4475-922c-57fa1db2536c/222817629054951f8f0053e18ab87f36/56307f2e57b70a0e79141500594dbeffd2271excscreenexample1.png)
From: Jay Carlson
I've put an initial release of client/server bindings for Lua for XML-RPC at [7]. It contains my lxp expat binding, and uses LuaSocket for client transport.
For more information on XML-RPC, see [8].
Although the packaging and documentation are scant, this package successfully passes the validation tests at [9].
SOAP
[LuaSOAP] is a Lua library to ease the use of SOAP.
Lua only XmlParser
For Lua 5.1:
From: Alexander Makeev
This XmlParser allows build object like C# XmlDocument? with XmlNodes?. See example for details.
example:
result:
RecentChanges · preferencesedit · history
Last edited March 20, 2019 11:15 pm GMT (diff)