@@ -15,10 +15,12 @@ * file. */ #include "config.h" +#define OF_XML_ELEMENT_M + #include #include #include @@ -189,11 +191,12 @@ - (instancetype)initWithElement: (OFXMLElement *)element { self = [super of_init]; @try { - if (element == nil) + if (element == nil || + ![element isKindOfClass: [OFXMLElement class]]) @throw [OFInvalidArgumentException exception]; _name = [element->_name copy]; _namespace = [element->_namespace copy]; _defaultNamespace = [element->_defaultNamespace copy]; @@ -758,10 +761,13 @@ return [element autorelease]; } - (void)addAttribute: (OFXMLAttribute *)attribute { + if (![attribute isKindOfClass: [OFXMLAttribute class]]) + @throw [OFInvalidArgumentException exception]; + if (_attributes == nil) _attributes = [[OFMutableArray alloc] init]; if ([self attributeForName: attribute->_name namespace: attribute->_namespace] == nil)