title: How to get an exact value from a website using php DOM and save it in a database?
body: <p>I want to get the span id "CPH1_lblCurrent" from the url and save it in the database.
  here is the code that i tried by seeing some examples.</p>
  
  <pre><code>&lt;?php
  $file = $DOCUMENT_ROOT. "http://www.mypetrolprice.com/2/Petrol-price-in-Delhi";
  $doc = new DOMDocument();
  $doc-&gt;loadHTMLFile($file);
  
  $xpath = new DOMXpath($doc);
  
  $elements = $xpath-&gt;query('//span[@id="CPH1_lblCurrent"]');
  if (!is_null($elements)) {
  foreach ($elements as $element) {
  
  
  $nodes = $element-&gt;childNodes;
  foreach ($nodes as $node) {
  echo $node-&gt;nodeValue. "\n";
  }
  }
  }
  ?&gt;
  </code></pre>
  
  <p>This shows me the following.</p>
  
  <pre><code>Current Delhi Petrol Price = 67.12 Rs/Ltr
  </code></pre>
  
  <p>but i want only the value 67.12. </p>
  
  <p>Can somebody help me.</p>