refactored analyze_xml.py a bit