+
+
+def xpath_query(xml_file, xpath):
+ """
+ Return a list of xml node corresponding to the xpath. The list can be of lenght
+ zero.
+ """
+ with open(xml_file, 'r') as f:
+ tree = etree.parse(f)
+ root = tree.getroot()
+ # Remove all namespace
+ # https://stackoverflow.com/questions/18159221/remove-namespace-and-prefix-from-xml-in-python-using-lxml
+ for elem in root.getiterator():
+ if not hasattr(elem.tag, 'find'):
+ continue
+ i = elem.tag.find('}')
+ if i >= 0:
+ elem.tag = elem.tag[i+1:]
+
+ return root.xpath(xpath)