List of usage examples for org.w3c.dom.html HTMLTableElement getRows
public HTMLCollection getRows();
THEAD
, TFOOT
, all TBODY
elements. From source file:org.sakaiproject.kernel.mailman.impl.MailmanManagerImpl.java
public List<String> getLists() throws MailmanException { HttpClient client = new HttpClient(proxyClientService.getHttpConnectionManager()); GetMethod get = new GetMethod(getMailmanUrl("/admin")); List<String> lists = new ArrayList<String>(); try {//from w ww . j a v a2 s .c om int result = client.executeMethod(get); if (result != HttpServletResponse.SC_OK) { LOGGER.warn("Got " + result + " from http request"); throw new MailmanException("Unable to list mailinglists"); } DOMParser parser = new DOMParser(); parser.parse(new InputSource(get.getResponseBodyAsStream())); Document doc = parser.getDocument(); NodeList tableNodes = doc.getElementsByTagName("table"); if (tableNodes.getLength() < 2) { throw new MailmanException("Unrecognised page format."); } HTMLTableElement mainTable = (HTMLTableElement) tableNodes.item(0); HTMLCollection rows = mainTable.getRows(); for (int i = 4; i < rows.getLength(); i++) { lists.add(parseListNameFromRow((HTMLTableRowElement) rows.item(i))); } } catch (SAXException e) { throw new MailmanException("Error parsing mailman response", e); } catch (HttpException e) { throw new MailmanException("HTTP Exception communicating with mailman server", e); } catch (IOException e) { throw new MailmanException("IOException communicating with mailman server", e); } finally { get.releaseConnection(); } return lists; }