Add the 
```
if 'media' not in ruleset.attrib: 
    continue
```