Im used to developing on .net so decided to try MonoMac, but unfortunately the WebBrowser control in .net isn't available in Mono.
Ive added a webview, and Ive figured out how to navigate:
wbWebView.MainFrameUrl = "http://www.linkedin.com";
Now for the life of me I can't figure out how to do these kinds of things I used to be able to do in .net:
wb.Document.GetElementById("email").SetAttribute("value", "myemaillogin@btinternet.com")
or stuff like this in .net:
For Each link As HtmlElement In wb.Document.GetElementsByTagName("a")
If link.GetAttribute("href").Contains("twitter") Then
Dim hyperlink As String = link.GetAttribute("href")
ListBox1.Items.Add(hyperlink)
End If
Next
(where wb is the webbrowser control in the above 2 examples)
Any ideas?
Ive tried looking at the xml approach, but either Im doing it wrong, but isn't really working for me. Its a shame there isn't the webbrowser control in mono!
Thanks very much for all your help.
ps. I know my .net examples are VB, but the same applies to C#
I figured it out...
- (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];