13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UIWebViewに表示されているXMLソースコードを取得する方法

Last updated at Posted at 2014-08-12

概要

UIWebViewに表示されているXMLのソースコードを取得する方法をメモ。
(HTMLの取得方法はすぐ見つかったのですが、XMLの方は少し探す必要があったので)

HTMLの場合

まずは、HTMLソースを取得する方法。

NSString *fullHtml = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('html')[0].outerHTML"];

XMLの場合

XMLのソースコードを取得する方法。

NSString *webViewBody = [webView stringByEvaluatingJavaScriptFromString: @"(new XMLSerializer()).serializeToString(document);"];

参考にさせていただいたページ

以上

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?