Hi, XPath matching doesn't care about prefices in the instance document searched. Although possible, it's by no means straightforward to write an XPath that matches a particular prefix.
Beware: The prefix you use in writing your XPath expressions has no relationship whatsoever to the prefix of the node in the instance document. What counts in the matching are the URIs these prefices are bound to, plus the local names, of course. These two things equal in the XPath expression and in a node in the instance document, the node is matched. You could well have the default prefix in the instance document, while in XPath you have to use an explicit prefix, should the nodes be namespace-qualified. The prefices can differ. Example: The XPath expression //x:stuff where prefix x is bound to 'urn:xmlns:com.example.stuff-1.0' will match the following elements: <x:stuff xmlns:x="urn:xmlns:com.example.stuff-1.0"/> <y:stuff xmlns:y="urn:xmlns:com.example.stuff-1.0"/> <my-weird-prefix:stuff xmlns:my-weird-prefix="urn:xmlns:com.example.stuff-1.0"/> <stuff xmlns="urn:xmlns:com.example.stuff-1.0"/> Jan Dvorak MathAn Praha, Ltd. | Hi, | | I find myself doing things like: | | private Map uris = new HashMap(); | uris.put("m",NAMESPACE); | org.dom4j.XPath xpath = doc.createXPath("//m:what/m:ever"); | xpath.setNamespaceURIs(uris); | org.dom4j.Node node = xpathSel.selectSingleNode(doc); | | Instead of | | doc.selectSingleNode("//?:what/?:ever"); | | Because I know the namespace URI but not the prefix (which could be the | default prefix). | | Is there an easier way to select a node using an xpath when I don't know | the prefix? | | -Tom ------------------------------------------------------- This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en _______________________________________________ dom4j-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev