title: Scrape values from a javascript tag depending on a variable inside
body: <p>I am writing a PHP script to get some javascript variables values (geographic coordinates) that can be found inside a single <code>&lt;script&gt;</code> tag, </p>
  
  <pre><code>&lt;script&gt;
  ....
  myFirstVariableValue = 58.922;
  mySecondVariableValue = -12.179;
  ....
  myLastVariableValue = 45.425;
  ....
  &lt;/script&gt;
  </code></pre>
  
  <p>I don't like the idea to get the whole HTML (it's huge) and use a regular expression for each of my variables on the whole page content, so I was thinking to use xpath to find the right script tag (there are many and many of them) and then get the variables.</p>
  
  <pre><code>preg_match("myFirstVariableValue\ =\ (-?\d+.\d+)/",$HTML,$matches);
  preg_match("mySecondVariableValue\ =\ (-?\d+.\d+)/",$HTML,$matches);
  ...
  preg_match("myLastVariableValue\ =\ (-?\d+.\d+)/",$HTML,$matches);
  </code></pre>
  
  <p>So, I would like to find with an xpath query the right script tag, and then run the regular expressions on the script tag content only. </p>
  
  <p>The problem is the xpath query: is it even possible to do something like this ?</p>