Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 22, 2012, 10:56 AM   #1
tradingjam
macrumors newbie
 
Join Date: Nov 2008
DOMHTMLElement & DOMNodeList innerHTML property question...

Hi All,

Im trying to cycle through a list of all the links on a page... I have a WebView called "myWebView" and have got this far:

Code:
[[[self myWebView] mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.bbc.co.uk/news/"]]];
    
    DOMDocument *myDomDocument = [[self myWebView] mainFrameDocument];
    
    DOMNodeList *myList = [myDomDocument getElementsByTagName:@"a"];
Now Im after the properties InnerHTML and OuterHTML - but these properties look like they're only available in a DOMHTMLElement object....

So I have a DOMNodeList object called myList, but I want to be able to cycle through them where I can access each node as a DOMHTMLElement object, so that I can get the InnerHTML and OuterHTML properties.

Any ideas?

Ive been picking my brains and searching for the past week, to no avail. Any help would be greatly appreciated!

Thanks
tradingjam is offline   0 Reply With Quote
Old Jul 24, 2012, 03:07 PM   #2
tradingjam
Thread Starter
macrumors newbie
 
Join Date: Nov 2008
I figured it out...

Code:
- (IBAction)btnDoStuff:(NSButton *)sender {
    [[[self myWebView] mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.bbc.co.uk/news/"]]];
    
    [[self myWebView] setEditable:YES];
   
    
}

- (IBAction)btnCoolCode:(NSButton *)sender {
    NSMutableArray *myArray = [[NSMutableArray alloc] init];
    
    DOMDocument *myDomDocument = [[self myWebView] mainFrameDocument];
    
    DOMNodeList *myList = [myDomDocument getElementsByTagName:@"a"];
    
    int numElements = [myList length];
    
    for (int i=0; i<numElements; i++) {
        [myArray addObject:(DOMHTMLElement *)[myList item:i]];
    }
        
    self.lblOutput.stringValue = [[myArray objectAtIndex:7] innerText];
tradingjam is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:51 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC