javascript - Query a nested HTML tag to return the value of it's attribute in PHP -
what best way have php query div class active
, query div inside of class content
has attribute song
, have return value string?
i have code looks this:
$xpath = new domxpath($doc); $resulted = $xpath->query('div[@class="active"]'); $active= $resulted->item->query('div[@class="content"]');
but it's been running errors:
fatal error: call member function query() on non-object
my javascript generated html:
<div class="item active" style="display: block; left: 685.5753504672897px; top: 0px; height: 475.3125px; width: 318.84929906542055px; font-size: 100%; z-index: 32768; visibility: visible;"> <canvas class="content landscape" href="#" src="imgs/dead.jpg" title="the dead weather - horehound" id="3" num="0" song="horehound" origproportion="1.0062305295950156" width="323" height="482"></canvas></div>
i feel isn't right way go this, since new not sure, , i've seen there many ways. i'm looking best/simplest way.
if got correctly, have like
$xpath = new domxpath($doc); $resulted = $xpath->query('div[@class="active"]'); foreach($resulted $result){ $active= $result->item->query('div[@class="content"]'); }
if not wanted do. please let me know
Comments
Post a Comment