code: def tag_to_dict(html):
      
  
      element = document_fromstring(html).xpath("//html/body/child::*")[0]
      attributes = dict(element.attrib)
      attributes["text"] = element.text_content()
      return attributes
docs: Extract tag's attributes into a `dict`.