• 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: Jim Correia <email@hidden>
  • Date: Sat, 4 Mar 2006 23:12:03 -0500

On Mar 4, 2006, at 11:29 AM, malcom wrote:

This is a short part of my code. Is there another way to convert
automatically <? Or need I do to it with replace functions of
NSString?

[...]

NSXMLElement *quoteNode = [[NSXMLElement alloc] initWithKind:
NSXMLElementKind options:NSXMLNodePreserveAll];
[quoteNode setName: @"QUOTE"];
[quoteNode setStringValue: [NSString
stringWithFormat:@"%d", [[_text
objectAtIndex:k] state]]];

It seems like you are going out of your way to make things more difficult than they need to be. Using the NSXMLElement convenience methods, and you'll the the right answer as an added bonus.


NSXMLElement *rootElement = [NSXMLNode elementWithName: @"root"];
NSXMLDocument *xmlDocument = [NSXMLNode documentWithRootElement: rootElement];

NSXMLElement *subElement = [NSXMLNode elementWithName: @"subelement" stringValue: @"<?"];
[rootElement addChild: subElement];


NSData *xmlData = [xmlDocument XMLData];
NSString *xmlString = [[[NSString alloc] initWithData: xmlData encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"%@", xmlString);



_______________________________________________ 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: malcom <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>)
 >Re: NSXMLDocument question (From: malcom <email@hidden>)
 >Re: NSXMLDocument question (From: Sarah Wilkin <email@hidden>)
 >Re: NSXMLDocument question (From: malcom <email@hidden>)

  • Prev by Date: Re: Bezier drawing tool suggestions?
  • Next by Date: controlTextDid... and the cursor: 2 questions
  • Previous by thread: Re: NSXMLDocument question
  • Next by thread: Re: NSXMLDocument question
  • Index(es):
    • Date
    • Thread