Most JavaScript scripts in pages are "hidden", i.e. they have <!-- before and ---> after the actual script text. When I try to use the following code: $html = new DOMDocument(); @$html->loadHTMLFile($url); // fetch the remote HTML file and parse it $xml = simplexml_import_dom($html); // convert the DOM object to a SimpleXML object. //Parsing the JavaScript foreach ($xml->xpath('//script') as $node){ echo (string) $node; } PHP: it only outputs the contents of the <script> tags, that do not have those comments in them. Is there any way to get the contents of those "hidden" scripts. Thanks for your help.