コード例 #1
0
  private List<Photo> convertAll(XmlDom xml) {

    List<XmlDom> entries = xml.children("entry");

    List<Photo> result = new ArrayList<Photo>();

    for (XmlDom entry : entries) {
      result.add(convert(entry));
    }

    return result;
  }
コード例 #2
0
  private Photo convert(XmlDom xml) {

    String url = xml.child("content").attr("src");
    String title = xml.child("title").text();
    String author = xml.child("author").text("name");

    String tb = url;
    List<XmlDom> tbs = xml.tags("media:thumbnail");

    if (tbs.size() > 0) {
      // tb = tbs.get(0).attr("url");
      tb = tbs.get(tbs.size() - 1).attr("url");
    }

    tb = tb.replaceAll("https:", "http:");

    Photo photo = new Photo();
    photo.url = url;
    photo.tb = tb;
    photo.title = title;
    photo.author = author;

    return photo;
  }
コード例 #3
0
  /**
   * Return the text content of the first matched tag. Short cut for "xml.child(tag).text()"
   *
   * <p>Return null if there's no matched tag.
   *
   * @param tag tag name
   * @return text
   * @see testText2
   */
  public String text(String tag) {

    XmlDom dom = child(tag);
    if (dom == null) return null;
    return dom.text();
  }