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