diff --git a/mmdet/datasets/xml_style.py b/mmdet/datasets/xml_style.py
index 0a0a4b3f3617cb670e85baf6bd74e15d39ff5d64..71069488b0f6da3b37e588228f44460ce5f00679 100644
--- a/mmdet/datasets/xml_style.py
+++ b/mmdet/datasets/xml_style.py
@@ -102,7 +102,8 @@ class XMLDataset(CustomDataset):
             if name not in self.CLASSES:
                 continue
             label = self.cat2label[name]
-            difficult = int(obj.find('difficult').text)
+            difficult = obj.find('difficult')
+            difficult = 0 if difficult is None else int(difficult.text)
             bnd_box = obj.find('bndbox')
             # TODO: check whether it is necessary to use int
             # Coordinates may be float type