Thanks for the code. But that might not be too efficient for large xml documents, since there would be a lot of looping for large xml documents.
I came up with an alternative that seems to work for my situation: // Get the namespace uri for inputDocument xml document if any String namespaceURI = inputDocument.getRootElement().getNamespace().getURI(); // Set the namespace uri HashMap map = new HashMap(); // Note: what prefix we choose to use for the namespace does not matter // In this case we just arbitrarily picked "w" as the prefix for the namespace map.put("w", namespaceURI); NamespaceContext namespaceContext = new SimpleNamespaceContext(map); String primaryXPath = "w:Document/w:[EMAIL PROTECTED]'Primary']/w:LOGIN/w:USERID"; String primaryUserId = getXmlElementUsingXPath(inputDocument, primaryXPath, namespaceContext) .getText(); And here is the implementation for the getXmlElementUsingXPath() method: private static Element getXmlElementUsingXPath(Document document, String xpathExpression, NamespaceContext namespaceContext) { try { XPath xpath = new Dom4jXPath(xpathExpression); xpath.setNamespaceContext(namespaceContext); return (Element) xpath.selectSingleNode(document); } catch (JaxenException e) { System.err.println("Trouble with Jaxen..."); e.printStackTrace(); return null; } } --- Evan Kirkconnell <[EMAIL PROTECTED]> wrote: > Have you not read our ongoing debate? It's very > related. :-) > > Basically, the answer is 'no', but I think it should > be 'yes'. If > you're bold enough to remove the namespaces, take a > look at code here: > > http://www.mail-archive.com/dom4j-user%40lists.sourceforge.net/msg02511.html > ********************************************************** * Saladin Sharif * e-mail: [EMAIL PROTECTED] * Visit homepage @ http://gaia.ecs.csus.edu/~sharifs ********************************************************** ____________________________________________________________________________________ Never Miss an Email Stay connected with Yahoo! Mail on your mobile. Get started! http://mobile.yahoo.com/services?promote=mail ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user