[webkit-dev] DOMDocument to NSXMLDocument

Darin Adler darin at apple.com
Thu Dec 13 16:46:41 PST 2007

On Dec 13, 2007, at 4:39 PM, Major Domo wrote:

> Speaking in terms of Objective C, what would be the best way to  
> convert an instance of DOMDocument into an instance of NSXMLDocument?

You'll need to serialize to an NSString, then parse it.

One way that might work, if you don't care about losing top level  
processing instructions that are outside the HTML element is this.

     [[document documentElement] outerHTML]

Then use initWithXMLString.

You could also write lots of Objective-C code to convert nodes one at  
a time. That would be a lot of code but it would work for even more  

     -- Darin

More information about the webkit-dev mailing list