I need to get an image and its title from html string. I heard, javascript may get elements via tags or ids, but I've never used javascript earlier. So I found a nice framework - JavaScriptCore and here's my code snippet:
JSContext* context = [[JSContext alloc] initWithVirtualMachine:[JSVirtualMachine new]];
NSString* jsString = [NSString stringWithFormat:@"var parser = new DOMParser();"
"var doc = parser.parseFromString(%@, \"text/html\");"
"var imgs = document.getElementsByTagName('img');", [htmlString stringByReplacingOccurrencesOfString:@"\n" withString:@""]];
[context evaluateScript:jsString];
But context[@"parser"], context[@"doc"] and context[@"imgs"] return undefined. What do I make wrong? Maybe I will be better to use some other approach without JavaScriptCore?