Server-side in PHP
A very basic way would be something like this:
$data = ''; // your HTML data from the question
preg_match( '/<div class="\st\">(.*?)<\/div>/', $data, $match );
Then iterate the $match
object. However, this could return bad data if your .st
DIV has another DIV inside it.
A more proper way would be:
function getData()
{
$dom = new DOMDocument;
$dom -> loadHTML( $data );
$divs = $dom -> getElementsByTagName('div');
foreach ( $divs as $div )
{
if ( $div -> hasAttribute('class') && strpos( $div -> getAttribute('class'), 'st' ) !== false )
{
return $div -> nodeValue;
}
}
}
Client-side
If you're using jQuery, it would be easy like this:
$('.st').text();
or
$('.st').html();
If you're using plain JavaScript, it would be a little complicated cause you'll have to check all DIV elements until you find the one with your desired CSS class:
function foo()
{
var divs = document.getElementsByTagName('div'), i;
for (i in divs)
{
if (divs[i].className.indexOf('st') > -1)
{
return divs[i].innerHTML;
}
}
}