In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of how to read and write XML in Android, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will have something to gain after reading this Android article on how to read and write XML. Let's take a look.
Android News Reader
The application will take an RSS feed from the popular Android developer site Androidster and parse it into a set of simple Java objects that you can use to build an Android ListView (see the download section for source code). This is a typical polymorphic behavior-providing different implementations of the same behavior (different XML parsing algorithms). Listing 1 shows how to build this model using an interface in the Java code.
Listing 1. XML feed parser interface
Java Code:
Package eoe.android; import java.util.List; public interface FeedParser {List
< Message >Parse ();}
Java Code:
Public class Message implements Comparable
< Message >{static SimpleDateFormat FORMATTER = new SimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss Z"); private String title; private URL link; private String description; private Date date; / / getters and setters omitted for brevity public void setLink (String link) {try {this.link = new URL (link);} catch (MalformedURLException e) {throw new RuntimeException (e);}} public String getDate () {return FORMATTER.format (this.date) } public void setDate (String date) {/ / pad the date if necessary while (! date.endsWith ("00")) {date + = "0";} try {this.date = FORMATTER.parse (date.trim ());} catch (ParseException e) {throw new RuntimeException (e) } @ Override public String toString () {/ / omitted for brevity} @ Override public int hashCode () {/ / omitted for brevity} @ Override public boolean equals (Object obj) {/ / omitted for brevity} / / sort by date public int compareTo (Message another) {if (another = = null) return 1; / / sort descending, most recent first return another.date.compareTo (date) }} this is the end of the article on "how to read and write XML in Android". Thank you for reading! I believe you all have a certain understanding of "how to read and write XML in Android". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.