Problem with CFTreeAppendChild ...
Problem with CFTreeAppendChild ...
- Subject: Problem with CFTreeAppendChild ...
- From: Erik Lehmann <email@hidden>
- Date: Wed, 11 Feb 2004 21:03:19 +0100
Hi there !
I wrote the following method, which works correctly in some
cases. I use this method to change values of known keys in an
XML structure and after that I write the changed tree back to the
file.
So if the XML entry is like that: "<key>Value</key>" the method
works great.
But if the entry in the input XML file is only "<Key/>" the method
puts the Value behind the Key, like that: "<key/>Value" but that9s
not right it should looks like that: "<key>Value</key>"
But I can't find the reason !!! So do someone have an idea
how to fix that problem ?
Best regards
ERIK
-(void)setStringValue:(NSString *)value forKey:(NSString *)key
{
CFXMLTreeRef descTree;
CFXMLTreeRef valueTree;
CFXMLNodeRef valueNode;
// Get tree of the Key which should be changed
descTree = XMLTreeDescendentNamed( (CFStringRef)key, _tree );
// Create the new Node with the new Content
valueNode = CFXMLNodeCreate (
kCFAllocatorDefault,
kCFXMLNodeTypeText,
(CFStringRef)value,
NULL,
kCFXMLNodeCurrentVersion);
valueTree = CFXMLTreeCreateWithNode(kCFAllocatorDefault,valueNode);
CFRelease(valueNode);
// Remove the old children of the key
CFTreeRemoveAllChildren(descTree);
// Add the changed values to the key
CFTreeAppendChild(descTree, valueTree);
CFRelease(valueTree);
CFRelease(descTree);
} // end setStringValue
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.