Arguments
- Name: tag, Type: str
- Name: attrs, Type: 2D list
- [0] attribute name, [1] attribute value
Source
def handle_starttag(self, tag, attrs):
if not self._is_started:
if tag.lower() == 'html':
node = pyNode('html')
self._is_started = True
self._dom.append(node)
self._nodes.append(node)
for attr in attrs:
node.set_attr(attr[0], attr[1])
else:
node = pyNode(tag.lower())
node.set_parent(self._dom[-1])
self._dom[-1].add_child(node)
if not is_self_closing(tag.lower()):
self._dom.append(node)
self._nodes.append(node)
for attr in attrs:
node.set_attr(attr[0], attr[1])