0

I am working on Android webView. I have an xPath with me and a webView. I want to evaluate the xPath on the webPage in the webView. Can anyone please help me with this? I tried the following code, but it didn't work.

XPath xpath = XPathFactory.newInstance().newXPath();
    String expression = "xpath expression";
    NodeList nodes = (NodeList) xpath.evaluate(expression, webView, XPathConstants.NODESET);

and I also saw this link. But I don't know how he got html.

Community
  • 1
  • 1
Droidme
  • 1,223
  • 6
  • 25
  • 45

1 Answers1

0

Create a JavaScriptInterface class as a Callback for retrieving HTML content from WebView. Here a sample tutorial.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
Pete Houston
  • 14,931
  • 6
  • 47
  • 60
  • thanks for that. what shoul be the type of variable html? I need to evaluate my xpath on it – Droidme Oct 18 '11 at 11:00
  • I tried the same way from the link u gvae. but getting the following warning 10-18 17:16:51.939: WARN/InputManagerService(67): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4069c180 this happens when i try to communicate from js to android – Droidme Oct 18 '11 at 12:06