This page was generated using Webiyo. See its source code and unit tests.
|
org/webiyo/examples/sourceforge/NewsItem.javapackage org.webiyo.examples.sourceforge; import org.w3c.dom.Element; import org.webiyo.web.HtmlText; import org.webiyo.xml.Xml; import java.io.IOException; class NewsItem { private final String title; private final HtmlText body; public NewsItem(Element itemElt) throws IOException { title = Xml.selectElement(itemElt, "title").getTextContent(); String description = Xml.selectElement(itemElt, "description").getTextContent(); body = new HtmlText("<p>" + removeCommentsLink(description) + "</p>"); } private static String removeCommentsLink(String description) { return description.replaceAll(" \\(<a href=\"[^\"]*\">\\d+ comments</a>\\)$", ""); } public String getTitle() { return title; } public HtmlText getBody() { return body; } } |