On Tuesday 22 June 2004 17:10, you wrote:Document doc = ...; XPath xpath = doc.createXPath("/html:html/html:head/html:title"); // manually tell the xpath about our prefix xpath.setNamespaceContext(Collections.singletonMap("html", "http://www.w3.org/1999/xhtml");
There's no XPath.setNamespaceContext(Map).
Sorry, its XPath.setNamespaceURIs(Map)
Element titleElem = (Element)xpath.selectSingleNode(doc);
Can't I simply ignore the namespace somehow? I want to apply one XPath expression to all docs.
As I workaround I could do a
Node n =
dom.selectSingleNode("/HTML/*[local-name()='HEAD']/*[local- name()='TITLE']");
but this is ugly... :-(
This is how the XPath spec is defined, so the only way to ignore the namespace is to remove it from all your documents. You should be able to apply a single XPath to many documents however, since you can tell the XPath processor what your prefixes are, separately from the prefixes actually defined in the document. The sample code from my previous email would work on any document, as long as the the HTML namespace had been declared, as your sample document did.
christian.
------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user