symfony - DomCrawler complex div nesting -
i'm having trouble trying data using dom crawler. want name 'avocado' , '£1.50' though i'd able
$message = $crawler->filterxpath('h3')->text(); <div class="product"> <div class="productinner"> <div class="productinfowrapper"> <div class="productinfo"> <h3> <a href="http://website.com" > avocado <img src="pic.jpg" alt="" /> </a> </h3> </div> </div> <div class="pricingandtrolleyoptions"> <div class="pricing"> <p class="priceperunit"> £1.50<abbr title="per">/</abbr><abbr title="unit"><span class="priceperunitunit">unit</span></abbr> </p> <p class="pricepermeasure">£1.50<abbr title="per">/</abbr><abbr title="each"><span class="pricepermeasuremeasure">ea</span></abbr> </p> </div> </div> </div>
to h3 text:
$message = $crawler->filterxpath('//div[@class="productinfo"]/h3')->text();
to price (i.e. class pricepermeasure):
$price= $crawler->filterxpath('//p[@class="pricepermeasure"]')->text();
Comments
Post a Comment