def get_css_class_dict(node):
"""
Given an xml.dom.minidom.Node, returns a map from every "class" attribute
from it to a list of nodes with this class.
For example, for the document below:
>>> doc = xml.dom.minidom.parseString(
... '''
... <html>
... <body>
... <div class="a b"><span class="a"></span></div>
... </body>
... </html>
... ''')
...we will get this:
>>> d = get_css_class_dict(doc)
>>> d['a'] # doctest: +ELLIPSIS
[<DOM Element: div at ...>, <DOM Element: span at ...>]
>>> d['b'] # doctest: +ELLIPSIS
[<DOM Element: span at ...>]
"""
pass
Comments