Touch Java soon, I have a harvest, and recently want to do a web version of the RSS reader to exercise. There are several OPML files that are exported from different versions of Foxmail, and you should know that OPML files are in XML format. So let's start here and practice reading XML files using DOM4J.
In Java programming, especially Java Web Development program, XML application frequency is very high. All kinds of web frameworks, such as Spring, Hibernate, struts, MyEclipse, Oracle, and so on, are mainly based on XML. XML can be said to have a vital role in the configuration of the system. And these also enhance the flexibility of the system.
First of all, the idea:
Creates a new Java Web project, but does not use Jsp,servlet for the time being. This article simply uses a self-contained debugger to test read XML first. In the next blog post, you will be shown in the optimized interface and provide most of the functions of the RSS reader.
The file format is slightly different because it is exported from different versions of Foxmail, and the main disagreement is on the subscription grouping feature. Some versions of the packet information is in the Head/title content, Body/outline is all the subscription information, and some of the grouped information is in the Body/outline title and Text properties, and detailed subscription information is placed in the body/ In Outline/outline.
I want to do the system can support reading multiple OPML files, so need an RSS file list configuration file "Rss_config.xml", corresponding to an entity: Rssconfigbean.java, mainly contains OPML file path information, group information also need to come out separately, named "Rssteambean.java", including title and text two attributes and a list of subscription information. Subscription information is definitely independent, named "Rssbean.java", including text, title, XMLURL, Htmlurl, version, type six properties.
First, by reading Rss_config.xml, get all the OPML file paths, and then loop through the OPML, get the packet information and all the detailed subscription information under each group, and save it to the entity for the call display.
The light says no use, directly on the code:
①. opml file
"Single Packet Foxmail6.5.opml"
<?xml version= "1.0"?>
<opml version= "1.1" >
"Multi-group FOXMAIL7.OPML"
<?xml version= "1.0" encoding= "UTF-8"?> <opml version= "1.0" >
More Wonderful content: http://www.bianceng.cn/Programming/Java/