• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSXMLDocument question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSXMLDocument question
      • From: Sarah Wilkin <email@hidden>
References: 
 >NSXMLDocument question (From: malcom <email@hidden>)
 >Re: NSXMLDocument question (From: Ilan Volow <email@hidden>)
 >Re: NSXMLDocument question (From: Robert Walker <email@hidden>)
 >Re: NSXMLDocument question (From: John Stiles <email@hidden>)
 >Re: NSXMLDocument question (From: malcom <email@hidden>)
 >Re: NSXMLDocument question (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Replicating the system wide contextual menu
  • Next by Date: Advice on using NSCell
  • Previous by thread: Re: NSXMLDocument question
  • Next by thread: Re: NSXMLDocument question
  • Index(es):
    • Date
    • Thread