I use the HTML Unit to go to a web page, fill out some forms and click a button to go to the next web page. This new web page (called newPage in my code) is what I am extracting from the html source.
This method works fine in Netbeans (although it gives an excessive amount of warnings)
import org.jsoup.Jsoup;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
String username = "USERNAME", school = "SCHOOL", userpassword = "PASSWORD";
HtmlElement loginName = null;
HtmlElement password = null;
HtmlAnchor anchorByHref = null;
try {
WebClient webClient = new WebClient();
final HtmlPage page = webClient
.getPage("https://cupertino.schoolloop.com/portal/login?d=x&return_url=1325402408153");
loginName = page.getElementByName("login_name");
password = page.getElementByName("password");
loginName.setTextContent(username);
loginName.setAttribute("value", username);
password.setAttribute("value", userpassword);
password.setTextContent(userpassword);
anchorByHref = page
.getAnchorByHref("javascript:document.form.event_override.value='login';document.form.submit();");
HtmlPage newPage = anchorByHref.click();
webClient.waitForBackgroundJavaScript(10000);
String html = newPage.getWebResponse().getContentAsString();
message2.setText(html);
} catch (Exception e) {
e.printStackTrace();
}
}
However, Android is running in Eclipse, it says
01-02 17:38:54.099: E/dalvikvm(23163): Could not find class 'org.w3c.dom.css.CSSCharsetRule', referenced from method com.gargoylesoftware.htmlunit.javascript.host.css.CSSCharsetRule.getCharsetRule
in the logarithm.
Also, it does not set message2 text as html, I want to , although when I try to do this in Netbeans and print "html", it actually prints the full html source of the page!
, 2 . Eclipse html, , CSSCharsetRule. , .jar , , HTML 15.jars, , .
I have figured out that the error was due to not importing xml-apis-1.3.04.jar (which was imported in the Netbeans Project).
" Dalvik 1"
.
, Null html Dalvik?
.jar Eclipse ( , xml-apis Dalvik)

Jar Netbeans ()
