[jdom-interest] Tagsoup, JDOM, Xpath

Frank Cohen fcohen at pushtotest.com
Mon Feb 18 23:57:58 PST 2008

Hi JDOMistas!

I am having a problem using the XPather add-on to Firefox with JDOM  
and Tagsoup and hope one of you may be able to help me.

I point Firefox at
file=file2.html and use XPather to generate an XPath expression to  
point to the Type selection list in the second form. XPather gives me:

I then try to apply the XPath expression using JDOM and Tagsoup:

builder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser")
doc = builder.build( StringReader( html from http:// 
examples.pushtotest.com/responder/htmlresponder?file=file2.html ) )
xpathr = JDOMXPath( xpathexpr )
results = xpathr.selectNodes( doc )

and results returns no nodes.

I found that Tagsoup adds its own default namespace of 'h' with a  
value of 'http://www.w3.org/1999/xhtml'. An Xpath expression of '/ 
h:html/h:body/h:form[2]' returns the second form correctly.

I suspect this is some Tagsoup weirdness.

Anyone have an idea on why the full XPath expression to the select  
form element returns no nodes?


Frank Cohen, http://www.PushToTest.com, phone 408 871 0122
PushToTest, the open-source test automation company

More information about the jdom-interest mailing list