code: def _build_doc(self):
          
          from lxml.html import parse, fromstring, HTMLParser
          from lxml.etree import XMLSyntaxError
          parser = HTMLParser(recover=True, encoding=self.encoding)
  
          try:
              if _is_url(self.io):
                  with urlopen(self.io) as f:
                      r = parse(f, parser=parser)
              else:
                  # try to parse the input in the simplest way
                  r = parse(self.io, parser=parser)
              try:
                  r = r.getroot()
              except AttributeError:
                  pass
          except (UnicodeDecodeError, IOError) as e:
              # if the input is a blob of html goop
              if not _is_url(self.io):
                  r = fromstring(self.io, parser=parser)
  
                  try:
                      r = r.getroot()
                  except AttributeError:
                      pass
              else:
                  raise e
          else:
              if not hasattr(r, 'text_content'):
                  raise XMLSyntaxError("no text parsed from document", 0, 0, 0)
          return r
docs: Raises
          ------
          ValueError
              * If a URL that lxml cannot parse is passed.
  
          Exception
              * Any other ``Exception`` thrown. For example, trying to parse a
                URL that is syntactically correct on a machine with no internet
                connection will fail.
  
          See Also
          --------
          pandas.io.html._HtmlFrameParser._build_doc