I have little problem with parsing some data from one webpage.
I'm trying to get class name of certain div
.
Example:
< div class="stars b3"></div>
I want to save in array just b3
.
Is it possible to do this?
Thanks!
I have little problem with parsing some data from one webpage.
I'm trying to get class name of certain div
.
Example:
< div class="stars b3"></div>
I want to save in array just b3
.
Is it possible to do this?
Thanks!
See this:
<?php // http://stackoverflow.com/questions/4835300/php-dom-to-get-tag-class-with-multiple-css-class-name
$html = <<< HTML
<td class="pos" >
<a class="firstLink" href="Search/?List=200003000112097&sr=1" >
Firs link value
</a>
<br />
<a class="secondLink SecondClass" href="/Search/?KeyOpt=ALL" >
Second Link Value
</a>
</td
HTML;
$dom = new DOMDocument();
@$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate(
"/html/body//a[@class='secondLink SecondClass']"
);
echo $hrefs->item(0)->getAttribute('class');