Index: src/OFXMLElement.h ================================================================== --- src/OFXMLElement.h +++ src/OFXMLElement.h @@ -210,15 +210,29 @@ /** * \return An OFArray with the attributes of the element */ - (OFArray*)attributes; +/** + * Removes all children and adds the children from the specified array. + * + * \param children The new children to add + */ +- (void)setChildren: (OFArray*)children; + /** * \return An array with all children of the element */ - (OFArray*)children; +/** + * Removes all children and sets the string value to the specified string. + * + * \param value The new string value for the element + */ +- (void)setStringValue: (OFString*)value; + /** * \return A string with the string value of all children concatenated */ - (OFString*)stringValue; Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -257,15 +257,39 @@ - (OFArray*)attributes { return [[attributes copy] autorelease]; } + +- (void)setChildren: (OFArray*)children_ +{ + OFMutableArray *new = [children_ mutableCopy]; + + @try { + [children release]; + } @catch (id e) { + [new release]; + @throw e; + } + + children = new; +} - (OFArray*)children { return [[children copy] autorelease]; } + +- (void)setStringValue: (OFString*)value +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + + [self setChildren: [OFArray arrayWithObject: + [OFXMLElement elementWithCharacters: value]]]; + + [pool release]; +} - (OFString*)stringValue { OFAutoreleasePool *pool; OFMutableString *ret;