Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我应该使用什么 XPath 表达式来解析 Google XHTML 结果页面?我无法使用
XPathExpression expr = xpath.compile(".//li[@class='g']/div/h3/em/text()");
如果是 XHTML,您可能需要对表达式进行命名空间绑定
Namspace ns = NAmespave.getNamespace("x", "http://www.w3.org/1999/xhtml"); XPathExpression expr = xpath.compile( ".//x:li[@class='g']/x:div/x:h3/x:em/text()", null, null, ns);