getting BR-separated text via DOM in JS/JQuery?

Posted by Hellion on Stack Overflow See other posts from Stack Overflow or by Hellion
Published on 2010-05-25T19:48:52Z Indexed on 2010/05/25 19:51 UTC
Read the original article Hit count: 168

Filed under:
|
|
|

Hi all, I am writing a greasemonkey script that is parsing a page with the following general structure:

<table>
<tr><td><center>
<b><a href="show.php?who=IDNumber">(Account Name)</a></b>
 (#IDNumber)
<br> (Rank)
<br> (Title)
<p>
<b>Statistics:</b>
<br>
<table>
<tr><td>blah blah etc.
</td></tr></table></center></table>

I'm specifically trying to grab the (Title) part out of that. As you can see, however, it's set off only by a <BR> tag, has no ID of its own, is just part of the text of a <CENTER> tag, and that tag has a whole raft of other text associated with it.

Right now what I'm doing to get that is taking the innerHTML of the Center tag and using a regex on it to match for /<br>([A-Za-z ]*)<p><b>Statistics/. That is working okay for me, but it feels like there's gotta be a better way to pick that particular text out of there.

... So, is there a better way? Or should I complain to the site programmer that he needs to make that text more accessible? :-)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery