htmlparser

Parses a HTML document.

Methods

clear()

Clears the document text (deletes all lines)

getattrib(attr)

Returns the value of a tag attribute
returns: string

load(s)

Loads a document

parsing()

Returns true while still parsing the document
returns: boolean

reset()

Stops parsing the document, goes back to the beginning

setattrib(attr,s)

Sets the value of a tag attribute

stop()

Stops parsing the document

Properties

posintegerReturns the current position
tagcontentstringReturns the content of the current tag
taglineintegerReturns the line of the current tag
tagnamestringReturns the name of the current tag
tagposintegerReturns the position of the current tag

Example - Using htmlparser


html = [[
<html>
<a href="http://www.lua.org">Lua</a>
</html>
]]
p = scl.htmlparser:new()
p:load(html)
while p:parsing() do
 print(p.tagname)
 print(p:getattrib('href'))
end