Package: closure-html

Function parse

Lambda List

parse (input handler)


  • input -- a pathname, stream, string, or octet array
  • handler -- nil, or a HAX/SAX handler

Return Value

The return value of this function is determined by the handler argument; see below.


Parse the HTML document given as an argument, or referred to using a pathname.

input can have one of the following types:
  • pathname -- a Common Lisp pathname. Opens the file specified by the pathname parses it as an HTML document.
  • stream -- a Common Lisp stream that has already been opened.
  • array -- an (unsigned-byte 8) array. The array is parsed directly, and interpreted according to the encoding it specifies.
  • string/rod -- a rod (or string on unicode-capable implementations). Parses an XML document from the input string that has already undergone external-format decoding.

If handler is nil, the parser's internal representation of the document is returned. The result is equivalent to that returned using a PT builder as returned by make-pt-builder, but avoids creating the same representation twice.

Alternatively, handler can be a HAX handler (see hax:abstract-handler) or a SAX handler (see the SAX protocol in cxml). In this case, the document will be serialized to the specified handler, and the result of hax:end-document will be returned from this function. Note that the parser will currently always process the entire document before sending the first HAX event.

See also