You can also use setXPathNamespaceURIs(Map) in DocumentFactory to affect selectNodes() and selectSingleNode() for a DOM tree that you create with this Factory.

Here's a bit of code that I'm using since I'm writting a DOMServlet API and don't think that the user should have to mess with any namespace nonsense:
   /**
    *Recursively removes the namespace of the element and all its children.
    */
   public void removeNamespaces(Element elem){
elem.setQName( QName.get( elem.getName(), Namespace.NO_NAMESPACE, elem.getQualifiedName() ) );
       Node n = null;
       for(int i=0; i<elem.content().size(); i++){
           n = (Node)elem.content().get(i);
if(n.getNodeType() == Node.ATTRIBUTE_NODE) ( (Attribute)n ).setNamespace(Namespace.NO_NAMESPACE); if(n.getNodeType() == Node.ELEMENT_NODE) removeNamespaces( (Element)n ); }
   }

--Evan

Edwin Dankert wrote:
Try something like this:

HashMap map = new HashMap();
map.put( "html", "http://www.w3.org/1999/xhtml";);

XPath xpath = DocumentHelper.createXPath( "//html:[EMAIL PROTECTED]'aw1']");
xpath.setNamespaceURIs( map);

List nodes = xpath.selectNodes( root);

Regards,
Edwin
--
http://www.edankert.com/
N�HY޵隊X���'���u���[�������
ަ�k��!���W�~�鮆�zk��C� [EMAIL PROTECTED],���a{�
�,�H��4�m�����Z��jY�w��ǥrg�y$���~7ٸ�m�Νj��^���&�;�z���X��X���&�;�z�b��,���y�+��޶m����+-��.�ǟ�����+-��b�ا~�ݢn#�ǫ





-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to