Skip to content

Commit deb39a0

Browse files
author
Antoine Marcadet
committed
Fixed an issue where trimming characters was perform after each
characters found and not after
1 parent 2b534cc commit deb39a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

XMLReader.m

+4-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
158158
// Set the text property
159159
if ([textInProgress length] > 0)
160160
{
161-
[dictInProgress setObject:textInProgress forKey:kXMLReaderTextNodeKey];
161+
// trim after concatenating
162+
NSString *trimmedString = [textInProgress stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
163+
[dictInProgress setObject:[[trimmedString mutableCopy] autorelease] forKey:kXMLReaderTextNodeKey];
162164

163165
// Reset the text
164166
[textInProgress release];
@@ -172,7 +174,7 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
172174
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
173175
{
174176
// Build the text value
175-
[textInProgress appendString:[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
177+
[textInProgress appendString:string];
176178
}
177179

178180
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError

0 commit comments

Comments
 (0)