From: Christian S. <chr...@ne...> - 2003-06-25 12:59:15
|
Simon Kahl wrote: > Have just started using HTMLUnit and thank the authors for good software. > > I had this ...SimpleLog... error today when using JUnit using HTMLUnit. > The mail archives had a thread on this issue but no solution. I've > since found that using JUnit's swing GUI with 'Reload classes every run' > switched on causes the problem. This invokes its own classloader which > trips up the logging code. > > BTW, is their any plan to support XPath (eg. JXPath) for finding > elements in the DOM? theres nothing preventing you from using it today. Below are 2 (untested) snippets for Jaxen and JXPath (I prefer Jaxen). Note that the xpath expression has to be applied to the w3c DOM kept inside the page, and has to be mapped back to the HtmlElement after retreival. There has recently been some discussion about the need of the latter operation ;-). //Jaxen Code: ///// HtmlPage page = ...; XPath xpath = new DOMXPath("/HTML"); Element w3cHtml = (Element)xpath.selectNodes(page.getElement()).get(0); HtmlElement html = page.getHtmlElement(w3cElement); //JXPath ///// HtmlPage page = ...; CompiledExpression expr = JXPathContext.compile("/HTML"); JXPathContext context = JXPathContext.newContext(page.getDocument()); Iterator it = expr.iteratePointers(context); Element w3cHtml = (Element)it.next(); HtmlElement html = page.getHtmlElement(w3cElement); > > Thanks, > Simon > > > *Simon Kahl > Component Architect > Prophecy International Pty Ltd > *41 Dequetteville Terrace > KENT TOWN South Australia 5067 > Phone: + 61 8 8364 4411 > Fax: + 61 8 8364 4454 > Email: sim...@pr... > <mailto:sim...@pr...> > Web: _www.prophecyopen.com_ <http://www.prophecyopen.com/> & > _www.velatte.com_ > <http://www.velatte.com/>------------------------------------------------------- > This SF.Net email is sponsored by: INetU Attention Web Developers & > Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. > We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed > Hosting http://www.inetu.net/partner/index.php > _______________________________________________ HtmlUnit-develop mailing > list Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-develop |