function getXML()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1/index.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "user:password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
$res = curl_exec($ch);
return $res;
}
$xml_data = getXML();
$doc = new DOMDocument();
$doc->loadXML($xml_data);
$wms = $doc->getElementsByTagName('WowzaMediaServer');
$wmstotalactive = $wms->item(0)->getElementsByTagName("ConnectionsCurrent")->item(0)->nodeValue;
$wmstotaloutbytes = $wms->item(0)->getElementsByTagName("MessagesOutBytesRate")->item(0)->nodeValue;
so you extracted from xml the value from ConnectionsCurrent key and MessagesOutBytesRate
.
If your link does not need to auth remove :
curl_setopt($ch, CURLOPT_USERPWD, "user:password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…