Tagsoup, JDOM, Xpath

Frank Cohen <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
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
http://examples.pushtotest.com/responder/htmlresponder? 
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:
/html/body/form/form/p/font/font/table/tbody/tr[6]/td[2]/select

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 )
xpathr.addNamespace("h","http://www.w3.org/1999/xhtml")
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

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




_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.