XPATH使用namespace
XPath xpath = XPathFactory.newInstance().newXPath();NamespaceContext nsContext = new XHTMLNamespaceContext();xpath.setNamespaceContext(nsContext);XPathExpression expr = xpath.compile("//xhtml:TABLE");
public class XHTMLNamespaceContext implements NamespaceContext {@Overridepublic String getNamespaceURI(String prefix) {return "http://www.w3.org/1999/xhtml";}@Overridepublic String getPrefix(String namespaceURI) {throw new UnsupportedOperationException();}@Overridepublic Iterator getPrefixes(String namespaceURI) {throw new UnsupportedOperationException();}}