/** * @param xmlSample * @return * @throws MalformedURLException * @throws IOException */ protected HtmlElement createHtmlElement(String xmlSample) throws MalformedURLException, IOException { String xmlSampleWithTags = "<table><tr><div id=\"maxtest2\"" + xmlSample + "</div></tr></table>"; URL url = new URL("http://www.example.com"); StringWebResponse response = new StringWebResponse(xmlSampleWithTags, url); WebClient client = new WebClient(); HtmlPage page = HTMLParser.parseHtml(response, client.getCurrentWindow()); // HtmlElement element = page.getHtmlElementById("maxtest"); HtmlElement element = page.getHtmlElementById("maxtest2"); Iterable<HtmlElement> children = element.getChildElements(); Iterator<HtmlElement> iter = children.iterator(); return iter.next(); }