$doc = new DOMDocument();
$doc->loadXML($xml);
$src = $doc->documentElement->getAttribute('src');
XPath example using remote file
$doc = new DOMDocument();
$doc->loadHTMLFile($url);
$xpath = new DOMXpath($doc);
// Retrieve collections of script nodes
$allScripts = $xpath->query('//script');
$headScripts = $xpath->query('/html/head/script');
$bodyScripts = $xpath->query('/html/body/script');
// Get all scripts who's src attribute starts with "http://website.com"
$websiteScripts = $xpath->query('//script[starts-with(@src, "http://website.com")]');
if ($websiteScripts->length) {
// contains one or more matches
$src = $websiteScripts->item(0)->getAttribute('src');
}