如何访问通过 RequestBuilder 获取的 HTML 对象内的 DOM?以下是关于我的问题的缩短代码:
RequestBuilder requestBuilder = new RequestBuilder(
RequestBuilder.POST,
"/experiment.txt");
requestBuilder.setCallback(new RequestCallback() {
public void onResponseReceived(Request request, Response response) {
if (200 == response.getStatusCode()) {
HTML responseHTML = new HTML(response.getText());
//TODO parse responseHTML
}
}
public void onError(Request request, Throwable exception) {}
});
假设,以下是 的内容responseHTML
:
HTML responseHTML=new HTML(
"<div id='div_1'>my div 1</div>" +
"<div id='div_2'>my div 2</div>");
是否可以通过以下方式div_1
从内部获取responseHTML
:
responseHTML.getElementById("div_1");