php - How to read two or more attributes from the node in XPath? -
foe example : html:
<div id="1" class="op" style='display: none;'> <h4>a</h4> <h4 >b</h4> </div>
query:
$elements = $xpath->query("//div[@id='1']@style='display:none;']/@id/@style"); echo @id echo @style
but not work!
you have typo missing [
on query , use normalize-space
:
$elements = $xpath->query("//div[@id='1'][normalize-space(@style = 'display: none;')]"); if($elements->length > 0) { echo $elements->item(0)->getattribute('class'); // foreach($elements $e) { // } }
Comments
Post a Comment