Module expadom

expadom parser.

This parser is build on LuaExpat and parses a document (as a whole or in chunks) into the DOM structure.

Functions

closeParser (parser) Closes the parser and returns the parsed document.
createParser () Creates a new parser and accompanying DOM document.
getParserDocument (parser) Returns the document for a parser.
parseDocument (data) Parses an XML document into a DOM model.


Functions

closeParser (parser)
Closes the parser and returns the parsed document.

Parameters:

Returns:

    a complete parsed DOM document, or nil+err.
createParser ()
Creates a new parser and accompanying DOM document. This can be used to parse a document in chunks, otherwise use parseDocument as it is more convenient. The document will have a temporary root-element to start with, but that one will be replaced with the actual parsed one during parsing.

Returns:

    parser (a LuaExpat parser object) + DOM document (empty to start with)

Usage:

    local parser = expadom.createParser()
    for _, chunk in ipairs(chunks) do
      local a,b,c,d,e = parser:parse(chunk1)
      if not a then
        parser:close(parser)
        return a,b,c,d,e
      end
    end
    
    local doc,b,c,d,e = expadom.closeParser(parser)
    if not doc then
      return doc, a,b,c,d,e
    end
    
    -- 'doc' contains the xml document
getParserDocument (parser)
Returns the document for a parser.

Parameters:

Returns:

    a DOM document to which the parser will add.
parseDocument (data)
Parses an XML document into a DOM model. This method is easy to use if you have the full document already, and don't need to parse in chunks.

Parameters:

  • data string the input text to parse (complete XML document)

Returns:

    the Document object parsed, or nil+parse-error
generated by LDoc 1.4.6 Last updated 2022-04-22 13:38:32