Thank you Evan, Mark and Edwin!
Edwin's solution worked straight up... hooray. I actually thought of that but was sure it wouldn't work because I
thought all my elements in my document would need to be prefixed as well. Now I see that the prefix is just preventing
the XPath processor from ignoring the namespace.
When I saw Mark's solution, I remembered that I actually did that at some point in my murky past. However, it doesn't
seem to work this time... I get an XPathException on the local-name() function. Looked it up and that is the correct
function name. Weird. But, anyway, using a prefix is working, so I'm good.
Evan, I'm intrigued by your ideas, but with Edwin's solution working, I'm throwing this back over the fence to my
co-worker. I'll tuck away your code though and take a look at some point.
Thanks again!
b
PS: this gotcha isn't in the cookbook on the dom4j site is it? Maybe it should
be added to that...
Edwin Dankert wrote:
You should specify a prefix for your namespace and use this prefix
in your XPath expression.
The following should work:
Document document = reader.read(new File("findings.html"));
XPath xp = DocumentFactory.getInstance().createXPath(
"//xhtml:[EMAIL PROTECTED]'content_left']");
Map ns = new HashMap();
ns.put( "xhtml","http://www.w3.org/1999/xhtml");
xp.setNamespaceURIs( ns);
List nodes = xp.selectNodes( document.getRootElement());
Good luck,
Edwin
--
http://www.edankert.com/
N�HS^�隊X���'���u��<�ڂ�.���y�"��*m�x%jx.j���^�קvƩ�X�jب�ȧ��m�ݚ���v&��קv�^�+����j�Z���{az���^��h���n���)�{h�����ا��+h�(m�����Z��jY�w��ǥrg�y$���Oxḝn�mj��^���&�;�z���X��X���&�;�z�b��,���y�+��m����+-��.�ǟ�����+-��b�ا~�ݢn#�ǫ
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user