Re: Converting HTML entities to NSXMLNode tree
Re: Converting HTML entities to NSXMLNode tree
- Subject: Re: Converting HTML entities to NSXMLNode tree
- From: Ben Kazez <email@hidden>
- Date: Sat, 03 Sep 2005 23:56:01 -0400
On Sep 3, 2005, at 7:43 PM, Timothy Larkin wrote:
On Sep 3, 2005, at 9:51 AM, Ben Kazez wrote:
So, given a text node containing entity-ized XML, how do I convert
this into an NSXMLNode tree representation of the XML, beneath the
node?
I don't think I fully understand your problem, but I'll give a go at
a solution.
Given an NSString object (xml) containing a string of XML, you can
create an XML tree using
NSXMLDocument *doc = [[NSXMLDocument alloc] initWithXMLString:xml
options:NSXMLNodePrettyPrint error:nil];
Then you get the doc's root element, an instance of NSXMLElement,
with [NSXMLDocument rootElement]. From there you walk the tree by
iterating over [NSXMLNode children].
This is almost it; sorry if I was unclear. All that remained was
unescaping unescaping HTML entities, which I did using Buzz
Andersen's handy NSString category: http://www.scifihifi.com/weblog/
mac/NSString-Entities.html (a wrapper for
CFXMLCreateStringByUnescapingEntities().
Thanks for the help.
Ben
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden