1

我想在 j2me 中从网页中提取文本,我使用了字符串操作,但我没有得到结果,我的代码是否正确?

来自网页的字符串:

<td align="left" valign="middle"  class="celebrity-details-description-txt" > 

<p style="text-align: justify;">

 Hero Gopichand's new movie under the direction of Chandrasekhar Yeleti is progressing at brisk pace in Ladakh. Recently, the unit has shot an extensive action scene on Gopichand, Taapsee and others under Buzkashi sport backdrop. alt="Buzkashi sport, gopichand buzkashi, gopichand new movie, buzkashi afghanisthan sport

</p> 

<p style="text-align: justify;">&nbsp;</p> <p style="text-align: justify;">&nbsp;</p>

</td>

这是我的代码:

int tdIndex = readUrl.indexOf("<td align=\"left\" valign=\"middle\" class=\"celebrity-details-description-txt\">");
tdIndex = readUrl.indexOf(">", tdIndex);
int endtdIndex = readUrl.indexOf("</td>", tdIndex);
String content = readUrl.substring(tdIndex + 1, endtdIndex);
4

1 回答 1

3

看起来在readUrlString 之间middle和之间有一个额外class的空间td。我的建议是改变

int tdIndex = readUrl.indexOf("&lt;td align=\"left\" valign=\"middle\" class=\"celebrity-details-description-txt\">");

只是

int tdIndex = readUrl.indexOf("class=\"celebrity-details-description-txt\"");
于 2012-08-24T12:47:12.393 回答