In the following scenario we have a String
that is the raw HTML
from any page (It can be as larger as you want) and we have to find some values (That HTML
does not have any Id
or clases
)
In that large String
with html code we have to extract some values and save them on variables, in this example the value of total of credits (60).
String response = "...
<BR>
<FONT COLOR="NAVY" FACE="ARIAL" SIZE="2">
<B>TOTAL CREDITS:</B>&NBSP; 60
</FONT>
<BR>
..."
What is the best way to extract that value?.
What I do is to indentify a unique prefix
, I cut the String at that point, and then I cut the sufix
.
String value = response.split("TOTAL CREDITS:</B>&NBSP;")[1].split("</FONT>")[0].trim();
Is there a better way to do that?