• 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: "Andrew R. Kinnie" <email@hidden>
  • Date: Fri, 29 Aug 2008 08:00:27 -0400

Thanks, I have no idea how I missed that.

Exactly what I was looking for!

Andrew

On Aug 28, 2008, at 9:40 PM, Graff wrote:

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


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

  • Prev by Date: Convert unicode string into ascii
  • Next by Date: Image in NSOutlineView
  • Previous by thread: Re: NSXMLNode and NSXMLElement issue
  • Next by thread: [Meet] LA CocoaHeads tonight, 8/28 7:30pm
  • Index(es):
    • Date
    • Thread