简体   繁体   中英

Android XML Rich Text Processing

I used the tutorial listed here to parse my XML:

http://android-er.blogspot.com/2010/05/simple-rss-reader-iii-show-details-once.html

The problem I am having is when I try to read in the XML description tag all I get is this:

<

The "<" symbol is where the description should go. This is the feed I am reading: http://www.calvaryccm.com/rss/devos.ashx

Please help me solve my issue in getting the real text into the description. Thank you!

I just created an android project in eclipse using the code I downloaded from the site you listed above. I only made one modification to the original sources. I changed line 33 in AndroidRssReader.java to read:

            URL rssUrl = new URL("http://www.calvaryccm.com/rss/devos.ashx");

The feed loads and parses fine. 在此处输入图片说明

The parsing error is the result of changes you made to the original sources.

I found out that I need to wrap my RSS tags in CDATA Tags as shown here:

Writing input for .NET web services

If the data is html encoded, you can use one of the following methods -- or if it is unencoded, you can surround the content in CDATA tags.

Spanned spannedContent = Html.fromHtml(htmlString);
textView.setText(spannedContent, BufferType.SPANNABLE);

or

WebView webview = (WebView) findViewById(R.id.aWebView);
String htmlString = "<html><body>Some html</body></html>";
webview.loadData(htmlString, "text/html", "utf-8");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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