Make middleware.py Python 2.6 compatible

Fixes bug 1206256

In Python 2.6 xml.etree.ElementTree.fromstring raises
xml.parsers.expat.ExpatError instead of
xml.etree.ElementTree.ParseError when faced with invalid xml.
This change catches an import error and uses ExpatError instead of
ParseError.

Change-Id: I8ab41328c8eeacc28f4e01d730c73ff251df4a25
Merge "Make middleware.py Python 2.6 compatible"