Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need to grab the text between a particular HTML element using regex in java

843834Sep 17 2008 — edited Sep 18 2008
I have following HTML
<tr>
<td>
<div class="stmtcol1">
<span class="tex1">$235.17</span>
</div>
</td>
<td>
<div class="stmtcol1">
<span class="tex2">$136.34</span>
</div>
</td>
</tr>

In my java program, I need to grab the text ONLY between <SPAN> element using some kind of regular expression based on the attribute class="tex1".

So ideally I am looking for the just "$235.17" from the above XML.

I googled enough but couldn't find anything specific.
When I used regular expression "(?<=^|>)[^><]+?(?=<|$)" I get all the text from my xml file.

Any help will be highly appreciated.

Edited by: pooleswa on Sep 17, 2008 10:09 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2008
Added on Sep 17 2008
2 comments
191 views