How to reach till the desired node in xpath result?

Jeoltalometus

New Member
One more weird question from me :\[code\]<?php$xpath = '//*[@id="topsection"]/div[3]/div[2]/div[1]/div/div[1]'; $html = new DOMDocument();@$html->loadHTMLFile('http://www.flipkart.com/samsung-galaxy-ace-s5830/p/itmdfndpgz4nbuft');$xml = simplexml_import_dom($html); if (!$xml) { echo 'Error while parsing the document'; exit;}$source = $xml->xpath($xpath);echo "<pre>";print_r($source);?>\[/code\]this is the source code. I am using to scrap price from a ecommerce.it works it gives below output :\[code\]Array( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [class] => line ) [div] => SimpleXMLElement Object ( [@attributes] => Array ( [class] => prices [itemprop] => offers [itemscope] => [itemtype] => http://schema.org/Offer ) [span] => Rs. 10300 [div] => (Prices inclusive of taxes) [meta] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [itemprop] => price [content] => Rs. 10300 ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [itemprop] => priceCurrency [content] => INR ) ) ) ) ))\[/code\]Now how to reach till directly [content] => Rs. 10300.i tried\[code\]echo $source[0]['div']['meta']['@attributes']['content']\[/code\]but it doesn't work.Hope some one can help.
 
Back
Top