diff --git a/Code/Support/Parsers/XML/RKXMLParserLibXML.m b/Code/Support/Parsers/XML/RKXMLParserLibXML.m index f24d90024c..4e720dddd7 100644 --- a/Code/Support/Parsers/XML/RKXMLParserLibXML.m +++ b/Code/Support/Parsers/XML/RKXMLParserLibXML.m @@ -37,6 +37,8 @@ - (id)parseNode:(xmlNode*)node { // Assume that empty strings are irrelevant and go for an attribute-collection instead if ([val length] == 0) { val = [NSMutableDictionary dictionary]; + attrs = [NSMutableDictionary dictionary]; + oldVal = [attrs valueForKey:nodeName]; NSMutableDictionary* elem = [NSMutableDictionary dictionaryWithObject:val forKey:nodeName]; [nodes addObject:elem]; } else { @@ -50,7 +52,7 @@ - (id)parseNode:(xmlNode*)node { } // Only add attributes to nodes if there actually is one. - if (![nodes containsObject:attrs]) { + if (![nodes containsObject:attrs] && [attrs count] > 0) { [nodes addObject:attrs]; } } else { diff --git a/Specs/Support/RKXMLParserSpec.m b/Specs/Support/RKXMLParserSpec.m index 037468f5dd..b2574ec55d 100644 --- a/Specs/Support/RKXMLParserSpec.m +++ b/Specs/Support/RKXMLParserSpec.m @@ -110,7 +110,8 @@ - (void)testShouldParseXMLWithAttributesInTextNodes { NSDictionary* exchangeRate = [result objectForKey:@"exchange_rate"]; assertThat(exchangeRate, is(notNilValue())); assertThat([exchangeRate objectForKey:@"type"], is(equalTo(@"XML_RATE_TYPE_EBNK_MIDDLE"))); - assertThat([exchangeRate objectForKey:@"valid_from"], is(equalTo(@"2011-08-03 00:00:00.0"))); + assertThat([exchangeRate objectForKey:@"valid_from"], is(equalTo(@"2011-08-03 00:00:00.0"))); + assertThat([exchangeRate objectForKey:@"name"], nilValue()); // This is to test for bug in parsing NSArray* currency = [exchangeRate objectForKey:@"currency"]; assertThat(currency, hasCountOf(3)); NSDictionary* firstCurrency = [currency objectAtIndex:0];