RSS development

xiaoxiao2021-03-06  42

RSS (Really Simple Syndication, truly simple chain) is a web content chain format. RSS becomes a standard format through web chain news content. As part of the contract with Sun Microsystems, I am responsible for developing any "JSP label library" that knows RSS, JavaServer Pages and HTML. Taglib mainly uses the non-technical editor of the Web site of the news content to collect the news content. My goal is to develop JSP tag libraries that will simplify the use of RSS content (0.91, 0.92 and 2.0 versions) in the web page.

RSS Utilities Package is the result of the project. It includes a set of custom JSP tags that compensate for RSS Utilities Tag Library and flexible RSS syntax analyzers. This document illustrates how to use the library provided by this grammar analyzer and RSS Utilities Package. Click here to download the first version. The zip file contains a JAR file rsSutils.jar (this file contains classes needed to use this tool) and a TLD file (this file defines the JSP custom label extracted from the RSS document).

Install Taglib

Although it is easy to use the label library, you ask you to understand the WEB server's working principle and how to configure it. The first step is to download and decompress the package. Once the zip file has been decompressed, a copy of RSSUTILS. JAR and RSSTAGLIB.TLD is placed in the Web application / web-inf / lib directory. Add the following taglib to the web application /Web-inf/web.xml file: /web-inf/rssuse.tld / web -Inf / rsSUTILS.TLD

Use taglib

Once taglib is already installed in a web application, follow the steps below to use Taglib in the JSP page. First, add the following line to the top of the JSP page: <% @ Taglib URI = "/ Web-inf / rsSUTILS.TLD" prefix = "rss"%>

Second, use the Feed tab to add RSS feed to the JSP page, as shown in the following example:

The URL attribute of the "feed" tag must contain the URL of the RSS document. The FeedId property of the "feed" tag is arbitrary, which can be set to any value. However, we recommend that this property is in an intuitive in identifying RSS feed. If the application is behind the firewall, you can use the "Feed" taggers attribute named ProxyAddress and Proxyport to set the proxy attribute. If you don't know the proxy server address proxy port, please contact the network administrator. Here is an example: Once one or more RSS feeds are added to the page, you should use the remaining tags to extract almost any information from the feed. Here is an example that explains how to extract the title of the RSS Feed channel added above:

Taglib example

Example 1 (RSS 0.91): image:
Title:
link: < / b>
description:






  • Example 2 (RSS 0.92): iMage:
    Title:
    link:
    description:

      < li>

      Example 3 (RSS 2.0): image:
      Title:
      link:
      Description:
      COPYRIGHT:
      DOCS:
      generator:
      Language:
      Last Build Date:
      managing editor:
      Pub Date:
      X-Virus: 1 Skip Days:
      Skip Hours:
      TTL:

      • Br>
        How to use RSSPARSER?

        From a certain extent, the syntax analyzer is the by-product of the project. Although the syntax analyzer is developed with a label library, it is entirely included, it can be used in the Java application. However, to do this, it is clear that you need at least to know how to write basic Java code. (If you know how to write Hello World in Java language, there is no problem.)

        First download and decompress the package. Once rsSutils.jar is added to your classpath, use RssParserFactory instances to create a RSSPARSER interface: rssparser Parser = rssparserfactory.createDefault (); rss rss = parser.parse (NEW URL ("http://mydomain.com/ Document.RSS "));

        The RSS object generated by the grammatical analyzer is a Java object representation located in the RSS document in the URL provided. Use the method provided by RSS objects to get the handle of other RSS objects, such as Channels and Items. RssParser can also analyze the File objects and InputStream objects.

        Conclude

        RSS provides a simple way to add and maintain news and other content from all web sites. Even if RSS is a simple XML format, anywhere in the Web is analyzed from the XML document, and extract data can be a bit tricky - or at least monotonize - if you have to do it over again. RSS Utilities Package uses Custom Tag and XML Parsing technology to make the "real simple syndication" format to be named

转载请注明原文地址:https://www.9cbs.com/read-58743.html

New Post(0)