Re: NSXMLNode and NSXMLElement issue
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