how to remove space from the xpath node after execution?

Rotoorbimemon

New Member
Sorry, if I posted a weird question. Now, I am explaining it properly.I am trying to scrap a data from a web page say for example from: http://www.koolkart.com/nokia-lumia-800-p8251I am trying to get price of the device listed in the table near "saholic" it is "Rs. 17759/-" and xpath to it is \[code\]"//*[@id="price-chart"]/tbody/tr[1]/td[3]"\[/code\]Now, when I execute the xpath in chrome, it gives the price with space \[code\]" Rs. 17759/- "\[/code\]Now, when I execute it in php\[code\]<?php$xpath = '//*[@id="price-chart"]/tbody/tr[1]/td[3]'; $html = new DOMDocument();@$html->loadHTMLFile('http://www.koolkart.com/nokia-lumia-800-p8251');$xml = simplexml_import_dom($html); if (!$xml) { echo 'Error while parsing the document'; exit;}echo $xml;$source_image = $xml->xpath($xpath);print_r($source_image);?>\[/code\]it gives error !So, is there any solution how to remove those trailing spaces or any other way how to get that price?
 
Back
Top