Skip to content
Felix Böhm edited this page Jan 9, 2012 · 26 revisions

##Usage

var Parser = new htmlparser.Parser(<obj> handler[, <obj> options]);

##Events

Names for the keys of the handler object. Only functions are valid values (the parser will break otherwise).

  • onopentag( name, attributes)
  • onopentagname( name)
  • onattribute( name, value)
  • ontext( text)
  • onclosetag( name)
  • onprocessinginstruction( name, data)
  • oncomment( data)
  • oncommentend()
  • oncdatastart()
  • oncdataend()
  • onerror( error)
  • onreset()

##Methods ###write (alias: parseChunk) Parses a chunk of data and calls the corresponding callbacks.

###end (alias: done) Parses the end of the buffer and clears the stack, calls onend.

###reset Resets buffer & stack, calls onreset.

###parseComplete Resets the parser, parses the data & calls end.

##Option: xmlMode Indicates whether <script> and <style> tags should get special treatment. If false, their content will be text only. For RSS feeds and other XML content (not HTML), set this to true. Default: false.

##Option: lowerCaseTags If set to true, all tags will be lowercased. This has noticeable impact on speed, so it defaults to false.

Clone this wiki locally