简体   繁体   English

如何在WebView中传递HTML标记

[英]How to pass html tag in webview

I have to pass whole html tag in webview. 我必须在webview中传递整个html标签。

My url is- http://mobileecommerce.site247365.com/admin/catdata.xml 我的网址是-http: http://mobileecommerce.site247365.com/admin/catdata.xml

I parse cat_desc , please check url for first cat_desc 我解析cat_desc,请检查第一个cat_desc网址

    public class WebviewActivity extends Activity 
    {

        WebView mWebView;
    String s="first cat_desc from url";

    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        showPdf();
    }
    private void showPdf() 
    {
        WebView webview = new WebView(this); 
        setContentView(webview); 
        webview.getSettings().setJavaScriptEnabled(true); 
        webview.loadData(s, "text/html", "utf-8");
    }
}

Read about xml parsers. 了解有关XML解析器的信息。 Then you can check how to set the HTML code in the cat_desc tag into your webview. 然后,您可以检查如何将cat_desc标记中的HTML代码设置到您的Web视图中。

You can read about xml parsing in android here . 您可以在此处阅读有关android中xml解析的信息

Another option is, you can try to substring out the cat_desc tag content using regular string methods (substring, indexOf). 另一个选择是,您可以尝试使用常规字符串方法(substring,indexOf)对cat_desc标签内容进行子字符串化。 Use the method you are comfort with. 使用您习惯的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM