• 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: NSXMLNode and NSXMLElement issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXMLNode and NSXMLElement issue


  • Subject: Re: NSXMLNode and NSXMLElement issue
  • From: Graff <email@hidden>
  • Date: Thu, 28 Aug 2008 21:40:30 -0400

On Aug 28, 2008, at 3:11 PM, Andrew R. Kinnie wrote:

I am attempting to programmatically create an html (rather, xhtml) document using NSXMLDocument, NSXMLElement, etc.

I am able to create the document and it works, but I am not sure how to create text which is not inside a paragraph or another tag which can be a node.

You can do that with the NSXMLNode class method textWithStringValue:

example:

NSXMLElement *root = (NSXMLElement *)[NSXMLNode elementWithName:@"test"];
NSXMLDocument *aDoc = [[NSXMLDocument alloc] initWithRootElement:root];

[root addChild:[NSXMLNode textWithStringValue:@"some text"]];

NSString *aFile = [@"~/Desktop/test.txt" stringByExpandingTildeInPath];
[[aDoc XMLData] writeToFile:aFile atomically:YES];


result:

	<test>some text</test>

- Ken Bruno
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSXMLNode and NSXMLElement issue
      • From: "Andrew R. Kinnie" <email@hidden>
References: 
 >NSXMLNode and NSXMLElement issue (From: "Andrew R. Kinnie" <email@hidden>)

  • Prev by Date: Re: How do I create a PDF fle paginated according to my own rules?
  • Next by Date: Re: CoreData, SQLite and GUID
  • Previous by thread: Re: NSXMLNode and NSXMLElement issue
  • Next by thread: Re: NSXMLNode and NSXMLElement issue
  • Index(es):
    • Date
    • Thread