Пример #1
0
  /**
   * Extract the object <code>PARAM</code> tags from the child list.
   *
   * @return The list of object parameters (keys and values are String objects).
   */
  public HashMap createObjectParamsTable() {
    NodeList kids;
    Node node;
    Tag tag;
    String paramName;
    String paramValue;
    HashMap ret;

    ret = new HashMap();
    kids = getChildren();
    if (null != kids)
      for (int i = 0; i < kids.size(); i++) {
        node = children.elementAt(i);
        if (node instanceof Tag) {
          tag = (Tag) node;
          if (tag.getTagName().equals("PARAM")) {
            paramName = tag.getAttribute("NAME");
            if (null != paramName && 0 != paramName.length()) {
              paramValue = tag.getAttribute("VALUE");
              ret.put(paramName.toUpperCase(), paramValue);
            }
          }
        }
      }

    return (ret);
  }
Пример #2
0
  public List<Newsitem> parseContent(String content) throws Exception {
    List<Newsitem> newsitems = new ArrayList<Newsitem>();

    Tag newsDiv = this.extractTagByClassName(this.stripHtmlComments(content), "box_news");
    NodeList nodes = this.extractTagsByClassName(newsDiv.toHtml(), "subItem");

    for (int i = 0; i < nodes.size(); i++) {
      NewsitemImpl newsitem = new NewsitemImpl();
      Tag itemTable = (Tag) nodes.elementAt(i);

      Tag titleTag = this.extractTagByClassName(itemTable.toHtml(), "subItemtitle");
      newsitem.setTitle(titleTag.toPlainTextString());

      Node descriptionSpan =
          titleTag.getNextSibling().getNextSibling().getNextSibling().getNextSibling();
      newsitem.setDescription(
          descriptionSpan
              .toPlainTextString()
              .replaceAll("[^\\u0000-\\u00FF]", " ")
              .replace("&nbsp;Read More...", "")
              .trim());

      Tag linkTag = (Tag) extractLinks(itemTable.toHtml(), "/index.php.*").elementAt(0);
      newsitem.setUrl(URL_PREFIX + linkTag.getAttribute("href"));
      newsitems.add(newsitem);
    }
    return newsitems;
  }
 /**
  * Look up an attribute's value by Namespace name.
  *
  * <p>See {@link #getValue(int) getValue(int)} for a description of the possible values.
  *
  * @param uri The Namespace URI, or the empty String if the name has no Namespace URI.
  * @param localName The local name of the attribute.
  * @return The attribute value as a string, or null if the attribute is not in the list.
  */
 public String getValue(String uri, String localName) {
   return (mTag.getAttribute(localName));
 }