Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -425,13 +425,12 @@ indentation: (unsigned int)indentation level: (unsigned int)level { void *pool; char *cString; - size_t length, i, attributesCount; + size_t length, i; OFString *prefix, *parentPrefix; - OFXMLAttribute *const *attributesObjects; OFString *ret; OFString *defaultNS; pool = objc_autoreleasePoolPush(); @@ -516,26 +515,21 @@ i += [_namespace UTF8StringLength]; cString[i++] = '\''; } /* Attributes */ - attributesObjects = [_attributes objects]; - attributesCount = [_attributes count]; - - for (size_t j = 0; j < attributesCount; j++) { + for (OFXMLAttribute *attribute in _attributes) { void *pool2 = objc_autoreleasePoolPush(); - OFString *attributeName = [attributesObjects[j] name]; + OFString *attributeName = [attribute name]; OFString *attributePrefix = nil; - OFString *tmp = - [[attributesObjects[j] stringValue] stringByXMLEscaping]; + OFString *tmp = [[attribute stringValue] stringByXMLEscaping]; - if ([attributesObjects[j] namespace] != nil && + if ([attribute namespace] != nil && (attributePrefix = [allNamespaces objectForKey: - [attributesObjects[j] namespace]]) == nil) + [attribute namespace]]) == nil) @throw [OFUnboundNamespaceException - exceptionWithNamespace: [attributesObjects[j] - namespace] + exceptionWithNamespace: [attribute namespace] element: self]; length += [attributeName UTF8StringLength] + (attributePrefix != nil ? [attributePrefix UTF8StringLength] + 1 : 0) + @@ -568,50 +562,46 @@ objc_autoreleasePoolPop(pool2); } /* Childen */ if (_children != nil) { - OFXMLNode *const *childrenObjects = [_children objects]; - size_t childrenCount = [_children count]; OFDataArray *tmp = [OFDataArray dataArray]; bool indent; if (indentation > 0) { indent = true; - for (size_t j = 0; j < childrenCount; j++) { - if ([childrenObjects[j] isKindOfClass: - charactersClass] || [childrenObjects[j] - isKindOfClass: CDATAClass]) { + for (OFXMLNode *child in _children) { + if ([child isKindOfClass: charactersClass] || + [child isKindOfClass: CDATAClass]) { indent = false; break; } } } else indent = false; - for (size_t j = 0; j < childrenCount; j++) { - OFString *child; + for (OFXMLNode *child in _children) { + OFString *childString; unsigned int ind = (indent ? indentation : 0); if (ind) [tmp addItem: "\n"]; - if ([childrenObjects[j] isKindOfClass: - [OFXMLElement class]]) - child = [(OFXMLElement*)childrenObjects[j] + if ([child isKindOfClass: [OFXMLElement class]]) + childString = [(OFXMLElement*)child OF_XMLStringWithParent: self namespaces: allNamespaces indentation: ind level: level + 1]; else - child = [childrenObjects[j] + childString = [child XMLStringWithIndentation: ind level: level + 1]; - [tmp addItems: [child UTF8String] - count: [child UTF8StringLength]]; + [tmp addItems: [childString UTF8String] + count: [childString UTF8StringLength]]; } if (indent) [tmp addItem: "\n"];