开发者

Get XML from NSWebView

开发者 https://www.devze.com 2023-03-22 00:40 出处:网络
I have a NSWebView in which there is loaded XML data. I cannot get it with stringByEvaluatingJavaScriptFromString because JavaScript doesn\'t want to work with XML. How the hell am I supposed to get i

I have a NSWebView in which there is loaded XML data. I cannot get it with stringByEvaluatingJavaScriptFromString because JavaScript doesn't want to work with XML. How the hell am I supposed to get it? Why is it so 开发者_如何学JAVAannoying difficult to do something so simple? Creating XML from URL won't work.

How do I get XML from NSWebView into a NSString?


Do you need to use the WebView? I'd suggest just grabbing the data by itself:

NSString *content = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"example.com"]];


I've worked it out myself. Thing is that you have to take the xml from WebFrame and not from WebView. You can then convert the data into a string or whatever you need.

NSData *xmlData = [[myWebView mainFrame] dataSource] data];
0

精彩评论

暂无评论...
验证码 换一张
取 消