Re: NSXMLDocument question
Re: NSXMLDocument question
- Subject: Re: NSXMLDocument question
- From: malcom <email@hidden>
- Date: Fri, 3 Mar 2006 01:41:00 +0100
Ok I've just fixed it. However there is another problem when I try to
add a node to the xml file I get an assertion failure.
You can see here (I've pasted a screenshot of my xcode debugger):
http://img320.imageshack.us/img320/9302/wrong4aw.jpg
This is the code (but you can see it from screenshot)
// XML GENERATION
NSXMLElement *rootArticle = (NSXMLElement *)[NSXMLNode
elementWithName:@"ARTICLE"];
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc]
initWithRootElement:rootArticle];
[xmlDoc setVersion:@"1.0"];
[xmlDoc setCharacterEncoding:@"UTF-8"];
NSXMLElement *rootHeaders = (NSXMLElement *)[NSXMLNode
elementWithName:@"HEADER"];
NSXMLElement *rootText = (NSXMLElement *)[NSXMLNode
elementWithName:@"CONTENTS"];
[rootArticle addChild: rootHeaders];
[rootArticle addChild: rootText];
// HEADERS GENERATION
NSArray *_toshow = [NMStylesCreator _getShowedHeaders];
int k;
NSString *tag = nil;
NSString *value = nil;
for (k=0; k < [_toshow count]; k++) {
tag = [_toshow objectAtIndex:0];
value = [_art getHeaderForKey: tag];
if (value != nil) {
NSXMLNode *node = [[NSXMLNode alloc]
initWithKind:NSXMLAttributeKind options:NSXMLNodePreserveAll];
[node setName: [NSString stringWithFormat:@"TAG_%@",tag]];
[node setStringValue: value];
-------------------------------> THE ERROR IS HERE!
[rootHeaders addChild: node];
}
}
// writing
NSData *xmlData = [xmlDoc XMLDataWithOptions:NSXMLDocumentTidyHTML];
if (![xmlData writeToFile:@"/Users/malcom/Desktop/xmldata_yeah.xml"
atomically:YES]) {
NSBeep();
NSLog(@"Could not write document out...");
return NO;
}
What's wrong now?!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden