diff --git a/lizmap_server/get_feature_info.py b/lizmap_server/get_feature_info.py
index feac85ff..27a1cf24 100755
--- a/lizmap_server/get_feature_info.py
+++ b/lizmap_server/get_feature_info.py
@@ -50,6 +50,11 @@ def append_maptip(cls, string: str, layer_name: str, feature_id: Union[str, int]
""" Edit the XML GetFeatureInfo by adding a maptip for a given layer and feature ID. """
root = ET.fromstring(string)
for layer in root:
+
+ if layer.tag.upper() != 'LAYER':
+ # The XML can be
+ continue
+
if layer.attrib['name'] != layer_name:
continue
diff --git a/test/test_server_core.py b/test/test_server_core.py
index b38f778c..77749dcb 100755
--- a/test/test_server_core.py
+++ b/test/test_server_core.py
@@ -202,6 +202,7 @@ def test_edit_xml_get_feature_info_without_maptip(self):
def test_edit_xml_get_feature_info_with_maptip(self):
""" Test to edit a GetFeatureInfo xml with maptip. """
string = '''
+
@@ -219,6 +220,7 @@ def test_edit_xml_get_feature_info_with_maptip(self):
response = GetFeatureInfoFilter.append_maptip(string, "qgis_popup", 1, "foo")
expected = '''
+