• 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: Converting HTML entities to NSXMLNode tree
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: 3rd Party Components
  • Next by Date: NSTextView wrapping too soon
  • Previous by thread: Re: Converting HTML entities to NSXMLNode tree
  • Next by thread: Accessing Contents via OpenGL-View
  • Index(es):
    • Date
    • Thread