private String tableElementToString(Element tableElement) { StringBuilder result = new StringBuilder(); result.append("["); rowsToString(tableElement, result); result.append("]"); return result.toString(); }
private void colsToString(StringBuilder result, Element rowElement) { NodeList cols = rowElement.getElementsByTagName("col"); for (int col = 0; col < cols.getLength(); col++) { Element colElement = (Element) cols.item(col); result.append(colElement.getFirstChild().getNodeValue()); result.append(","); } result.deleteCharAt(result.length() - 1); }
private void rowsToString(Element tableElement, StringBuilder result) { NodeList rows = tableElement.getElementsByTagName("row"); for (int row = 0; row < rows.getLength(); row++) { result.append("["); Element rowElement = (Element) rows.item(row); colsToString(result, rowElement); result.append("],"); } result.deleteCharAt(result.length() - 1); }