Re: NSXMLNode and NSXMLElement issue
Re: NSXMLNode and NSXMLElement issue
- Subject: Re: NSXMLNode and NSXMLElement issue
- From: Nate Weaver <email@hidden>
- Date: Thu, 28 Aug 2008 14:51:03 -0500
You need to use NSXMLNode itself, and not NSXMLElement (since text
nodes aren't elements). [NSXMLNode textWithStringValue:someString] or -
[[NSXMLNode alloc] initWithKind:NSXMLTextKind], followed by -
setStringValue:. Then just addChild: or insertChild:atIndex: with your
new text node as normal.
HTH
On Aug 28, 2008, at 2:11 PM, Andrew R. Kinnie wrote:
Greetings:
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.
e.g.
<body>
<tag>contents</tag>
some random text
</body>
or
<body>
<h3>some header text</h3>
some random text
<ul>
<li> . . . . </li>
etc.
</ul>
</body>
It seems when programmatically creating a node, the node has a name,
which is the tag (e.g. h3 above) but how do you do this without
tags? The text itself, unwrapped by tags would be the node, but I
have no idea how to programmatically do this. I created node with
an empty name, but then the open tag actually is displayed in
safari. I tried a nil name, in which case the entire tag and it's
contents is ignored.
Another (and more directly relevant) example is bread crumbs:
<some link text> - <some other link text> - etc.
I was able to otherwise create text using div tags, but if I try
divs here (i.e. wrap the "-" in a div) I get:
<some link text>
-
<some other link text>
Any insight or ideas? What am I missing?
Andrew
_______________________________________________
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