I have the following content in a wordpress post
the_content()
<div class="directions">
<div class="left"> left </div>
<div class ="right"> right </div>
</div>
Using DOMXpath I want to extract and pint only div class "left". I tried this
<?php libxml_use_internal_errors(true); ?>
<?php libxml_disable_entity_loader(true); ?>
<?php $html = new DOMDocument();?>
<?php $content = get_the_content();?>
<?php $html->loadHTML($content);?>
<?php $xpath = new DOMXpath($html); ?>
<?php $xpath->query('//div[contains(@class, "left")]'); ?>
<?php echo $xpath -> textContent; ?>
Unfortunately, I get nothing returned. Does someone see my mistake?