<div id="dump-list">
<div class="dump-row">
<div class="dump-location odd" data-jmapping="{id: 35, point: {lng: -73.00898601, lat: 41.71727402}, category: 'office'}">
<div class="SingleLinkNoTx">
<a href="#10" class="loc-link">Acme Software</a><br/><strong>John Doe, MBA</strong><br/>123 Main St.<br />New York, NY 10036<br /><strong class="telephone">(212) 555-1234</strong><br/>
</div><!-- END.SingleLinkNoTx -->
<a href="http://www.example.com" target="_blank" class="web_link">Visit Website</a><span><br />(0.3 miles)</span>
<div class="loc-info">
<div class="loc-info-text ">
John Doe, MBA<br /><a href="http://maps.google.com/?daddr=41.71727402,-73.00898601" target="_blank">Get Directions »</a>
</div>
</div>
</div>
How is the above HTML parsed in PHP, so that non-class fields such as the company name, person’s name (John Doe, MBA), address, city, state zip code can be separated to their own variable using xpath? Thanks!
Something among the lines of:
$xpathis the xpath object with all the dom information, you can read more about it here. The evaluate function returns the content for the requested expression.The expression
//a[@class="loc-link"]//text()tell xpath to look for any anchorawith the class attribute set toloc-linkthen within the anchor look for any (nested) textnode.