我需要帮助将JSON Feed解析到我的Android应用中。问题是我的博客Feed正在返回带有HTML值的JSON Feed。
以下是Feed链接:https://www[.]xdablogs[.]com/feeds/posts/default?alt=json
这是一个小例子:
"content": {
"type": "html",
"$t": "<div dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"><h2 style=\"text-align: left;\">How to view saved WiFi passwords PC or Android</h2><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://1.bp.blogspot.com/-Dkqqi1-rK8s/VhYeSlpAA0I/AAAAAAAAH9A/GJps5_77rdI/s1600/how-to-view-saved-wifi-passwords-pc-or-android-logo.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" src=\"http://1.bp.blogspot.com/-Dkqqi1-rK8s/VhYeSlpAA0I/AAAAAAAAH9A/GJps5_77rdI/s1600/how-to-view-saved-wifi-passwords-pc-or-android-logo.png\" title=\"How to view saved WiFi passwords PC or Android\" /></a></div><div><br /></div><p style=\"text-align: justify;\">Hello friends i m not going to teach you about hacking wifi. I am just giving you technique to get saved wifi <a class=\"zem_slink\" href=\"http://en.wikipedia.org/wiki/Password\" rel=\"wikipedia\" target=\"_blank\" title=\"Password\">password</a> on your friend's windows PC or on <a class=\"zem_slink\" href=\"http://code.google.com/android/\" rel=\"homepage\" target=\"_blank\" title=\"Android\">Android mobile</a>. In windows its easy to retrive saved wifi password, because we need to enter single command in command prompt and you will get saved password. But in Android mobile you need to browse some folders to get wifi password. But its not different. Its also easy. follow given steps</p><h2>For <a class=\"zem_slink\" href=\"http://en.wikipedia.org/wiki/Microsoft_Windows\" rel=\"wikipedia\" target=\"_blank\" title=\"Microsoft Windows\">Windows PC</a> or Laptop :</h2><br /><h4>This will work on all versions of windows.</h4><ol><li>Open command prompt, shortcut to open command prompt is press windows<b> key + R</b> keys on keyboard. And type \"<a class=\"zem_slink\" href=\"http://en.wikipedia.org/wiki/Batch_file\" rel=\"wikipedia\" target=\"_blank\" title=\"Batch file\"><b>CMD</b></a>\" and press enter. otherwise goto Start and search \"<b>CMD</b>\" or \"<b>Comand Prompt</b>\"</li></ol><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://3.bp.blogspot.com/--VqeUBa8vhU/VhYeWIiiZqI/AAAAAAAAH-A/LIuCVILin34/s1600/how-to-view-saved-wifi-passwords-pc-or-android1.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"165\" src=\"http://3.bp.blogspot.com/--VqeUBa8vhU/VhYeWIiiZqI/AAAAAAAAH-A/LIuCVILin34/s320/how-to-view-saved-wifi-passwords-pc-or-android1.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"320\" /></a></div><div><br /></div><ol start=\"2\"><li>After opening <a class=\"zem_slink\" href=\"http://en.wikipedia.org/wiki/Command_Prompt\" rel=\"wikipedia\" target=\"_blank\" title=\"Command Prompt\"><b>Command Prompt</b></a> type the following line</li></ol><blockquote class=\"tr_bq\">netsh wlan show profile name=\"<a class=\"zem_slink\" href=\"http://en.wikipedia.org/wiki/Wi-Fi\" rel=\"wikipedia\" target=\"_blank\" title=\"Wi-Fi\">WiFi</a> Name\" key=clear </blockquote><br />Replace \"<b><i>WiFi Name</i></b>\" with actual name of WiFi network which you want to retrieve password. <br /><h3>for example :</h3><blockquote class=\"tr_bq\">netsh wlan show profile name=\"PR.G.\" key=clear </blockquote><br /><!-- adsense -->Now All Information about that WiFi network will be shown in Command Prompt, just scroll down and inside security section you will find you WiFi key. Just steal it. :D <br /><br /><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://2.bp.blogspot.com/-46n32JUs728/VhYeV0OWcfI/AAAAAAAAH-E/LNFrqPhszyc/s1600/how-to-view-saved-wifi-passwords-pc-or-android2.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"161\" src=\"http://2.bp.blogspot.com/-46n32JUs728/VhYeV0OWcfI/AAAAAAAAH-E/LNFrqPhszyc/s320/how-to-view-saved-wifi-passwords-pc-or-android2.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"320\" /></a></div><br /><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://1.bp.blogspot.com/-Q9txPUW_rrQ/VhYeWGsXH2I/AAAAAAAAH-I/KM-ijLZGP78/s1600/how-to-view-saved-wifi-passwords-pc-or-android3.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"161\" src=\"http://1.bp.blogspot.com/-Q9txPUW_rrQ/VhYeWGsXH2I/AAAAAAAAH-I/KM-ijLZGP78/s320/how-to-view-saved-wifi-passwords-pc-or-android3.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"320\" /></a></div><br /><h2>For Android (with Root read here <a href=\"https://www.google.com/url?q=http://www.xdablogs.com/2015/02/what-is-root-advantages-and.html&sa=U&ved=0CAgQFjABahUKEwjFouvYsbLIAhWJOogKHdlHC4Y&client=internal-uds-cse&usg=AFQjCNENxbyS1FLFH9kyG-wx6-AP-NdtHg\" rel=\"nofollow\" target=\"_blank\">how to Root</a>):</h2><ol><li>Download <a href=\"https://play.google.com/store/apps/details?id=com.estrongs.android.pop\" target=\"_blank\">ES File Explorer</a> from <a class=\"zem_slink\" href=\"http://en.wikipedia.org/wiki/Google_Play\" rel=\"wikipedia\" target=\"_blank\" title=\"Google Play\">google Play Store</a>.</li></ol><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://1.bp.blogspot.com/-2TN0XOLoiH4/VhYeSMUySQI/AAAAAAAAH9I/BdT9K3sC988/s1600/how-to-view-saved-wifi-passwords-pc-or-android-mobile.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"320\" src=\"http://1.bp.blogspot.com/-2TN0XOLoiH4/VhYeSMUySQI/AAAAAAAAH9I/BdT9K3sC988/s320/how-to-view-saved-wifi-passwords-pc-or-android-mobile.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"180\" /></a></div><div><br /></div><ol start=\"2\"><li>open <b>ES File Explorer</b> and open menu by swiping <b>left to Right</b>.</li><li>go down And turn on \"<b>Root Explorer</b>\".</li></ol><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://1.bp.blogspot.com/-T0nIz2eLhP8/VhYeStEi5-I/AAAAAAAAH9U/w1hpe9PgFJI/s1600/how-to-view-saved-wifi-passwords-pc-or-android-mobile2.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"320\" src=\"http://1.bp.blogspot.com/-T0nIz2eLhP8/VhYeStEi5-I/AAAAAAAAH9U/w1hpe9PgFJI/s320/how-to-view-saved-wifi-passwords-pc-or-android-mobile2.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"180\" /></a></div><div><br /></div><ol start=\"4\"><li>Now go up and tap on \"<b>/ Device</b>\"</li></ol><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://2.bp.blogspot.com/--ZAzC8gqmvQ/VhYeTUbgGvI/AAAAAAAAH9c/gfg3B3XRlVE/s1600/how-to-view-saved-wifi-passwords-pc-or-android-mobile3.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"320\" src=\"http://2.bp.blogspot.com/--ZAzC8gqmvQ/VhYeTUbgGvI/AAAAAAAAH9c/gfg3B3XRlVE/s320/how-to-view-saved-wifi-passwords-pc-or-android-mobile3.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"180\" /></a></div><div><br /></div><ol start=\"5\"><li>Now open \"<b>Data</b>\" folder, inside \"<b>Data</b>\" folder open \"<b>Misc</b>\" and then open \"<b>WiFi</b>\" folder.</li></ol><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://4.bp.blogspot.com/-mILnm3qVtCg/VhYeTrqsjzI/AAAAAAAAH9o/9bhgC9o6PYM/s1600/how-to-view-saved-wifi-passwords-pc-or-android-mobile4.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"320\" src=\"http://4.bp.blogspot.com/-mILnm3qVtCg/VhYeTrqsjzI/AAAAAAAAH9o/9bhgC9o6PYM/s320/how-to-view-saved-wifi-passwords-pc-or-android-mobile4.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"180\" /></a></div><div><br /></div><ol start=\"6\"><li>here will be a file named \"<b>wpa_supplicant.conf</b>\", open that file in any <a class=\"zem_slink\" href=\"http://en.wikipedia.org/wiki/Text_editor\" rel=\"wikipedia\" target=\"_blank\" title=\"Text editor\">Text Editor</a> or Text Viewer, to read contents inside that file.</li></ol><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://3.bp.blogspot.com/-A1BoqMX9Bvc/VhYeT7FgHYI/AAAAAAAAH9s/KGdWOC_TwZw/s1600/how-to-view-saved-wifi-passwords-pc-or-android-mobile5.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"320\" src=\"http://3.bp.blogspot.com/-A1BoqMX9Bvc/VhYeT7FgHYI/AAAAAAAAH9s/KGdWOC_TwZw/s320/how-to-view-saved-wifi-passwords-pc-or-android-mobile5.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"180\" /></a></div><div><br /></div><ol start=\"7\"><li>Inside that file you will get all saved Wifi name with Password.</li></ol><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://3.bp.blogspot.com/-mmiTp4ZRT2c/VhYeUWLF1MI/AAAAAAAAH9w/a1ioGihoIpM/s1600/how-to-view-saved-wifi-passwords-pc-or-android-mobile6.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img alt=\"How to view saved WiFi passwords PC or Android\" border=\"0\" height=\"320\" src=\"http://3.bp.blogspot.com/-mmiTp4ZRT2c/VhYeUWLF1MI/AAAAAAAAH9w/a1ioGihoIpM/s320/how-to-view-saved-wifi-passwords-pc-or-android-mobile6.png\" title=\"How to view saved WiFi passwords PC or Android\" width=\"180\" /></a></div><br /><p>So on Android mobile this will work if you have rooted your mobile, otherwise \"Data\" folder will be empty.</p></div><div class=\"blogger-post-footer\"><script type='text/javascript'>\n google_ad_client="ca-pub-7943122633795545";\n google_ad_slot="4444892313";\n google_ad_width=468;\n google_ad_height=60;\n</script>\n\n<script src='http://pagead2.googlesyndication.com/pagead/show_ads.js' type='text/javascript'></script></div>"
},
是否可以将整个html内容解析为Android应用程序,或者我需要将其转换为文本格式?
如果我需要将该html Feed转换为文字Feed,那么我该如何转换?我想为我的博客编写一个应用程序,该应用程序托管在博客上。
我找到了另一个使用此摘要的Feed
https://www[.]xdablogs[.]com/feeds/posts/summary?alt=json
但是在这个中提取了一些身体内容。有没有其他方法来获取正文的全部内容?
答案 0 :(得分:0)
您的对象类将如下所示:
class Feed {
@SerializedName("type")
private String mType;
@SerializedName("$t")
private String mContent;
// getters
}
从json转换为json String str:
Feed feed = new Gson().fromJson(str, Feed.class);
将您的数据传递到webView或textView
答案 1 :(得分:0)
是的,您可以将HTML内容传递到Android应用程序。
将HTML contains分配给String值, 然后使用HTML类将其分配给视图。 E.g。
String sFetchedHTMLData = <Your HTML Data that you had fetched using JSON>;
textView.setText(HTML.fromHTML(sFetchedHTMLData));
答案 2 :(得分:0)
如果您直接尝试在textView中显示html内容,请使用以下命令:
textView.setText(Html.fromHtml(htmlcode));