<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def htmlParseDoc(cur, encoding):
 """parse an HTML in-memory document and build a tree. """

    ret = libxml2mod.htmlParseDoc(cur, encoding)
    if ret is None:raise parserError('htmlParseDoc() failed')
    return xmlDoc(_obj=ret)