2

I want to get javascript variable printed out in the HTML code using DOMXPath,here is the HTML code

<body>
    <div></div>
<body>
<script>
  var $data = {"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]};
</script>

By using DOMXPath I can get access to every element inside body tag, but how can I deal with javascript variable, it seems it is not a a node, can DOMXPath deal with such situation, or I have to use other approaches such as Regex?

This HTML I'm getting data from is not from my own server, so I need to scrape it and store it on my local machine.

user7031
  • 435
  • 4
  • 16
  • 1
    Possible duplicate of [Using DOMDOCUMENT to pull JavaScript values](http://stackoverflow.com/questions/26423950/using-domdocument-to-pull-javascript-values) – khan Dec 14 '16 at 21:26
  • PHP will not execute javascript, so using regex's would work here. A good example is discussed in the this post: http://stackoverflow.com/questions/26423950/using-domdocument-to-pull-javascript-values – khan Dec 14 '16 at 17:24

0 Answers0