java - Generate XPath expression of Google search engine -
what xpath expression should use parse google xhtml results page? i'm not able retrieve using
xpathexpression expr = xpath.compile(".//li[@class='g']/div/h3/em/text()");
if it's xhtml, need namespace binding on expression
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);
Comments
Post a Comment