I'm trying to pull out some datas using the DOM Parser technique.
My code :
<?php
// create new DOMDocument
$document = new \DOMDocument('1.0', 'UTF-8');
// set error level
$internalErrors = libxml_use_internal_errors(true);
$data = '<div id="show">
<ul class="browse_in_widget_col">
<li>
<a href="accounting/">
Accounting
</a>
<span>
(7420)
</span>
</li>
</div>';
$dom = new DOMDocument();
$dom->loadHTML($data, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$xp = new DOMXPath($dom);
$makes = $xp->query('//ul[@class="browse_in_widget_col"]/ul');
$makeList = [];
foreach ( $makes as $make ) {
$makeList[] = $make->textContent;
}
print_r($makeList);
?>
Here i want to pull out the between the element <a> tag.
Example here i need Accounting from this element. How i can do that ?
Help me to get all the values in the a tag. Now I'm getting the empty array