- for node in html_tree.childNodes:
- if (node.name == 'html') and (node.type != 3): # Skip DocType element
- html = node
- break
- else:
- html = None
+ html = None
+ if hasattr(html_tree, 'childNodes'):
+ for node in html_tree.childNodes:
+ # Skip DocType element
+ if (node.name == 'html') and (node.type != 3):
+ html = node
+ break