title: Get live stats in XML with Wowza version 4
body: <p>I have this PHP script that gets stats from the Wowza Streaming Server version 4.</p>
  
  <p>The PHP script is working but I am only interested in the stats for the Live Streams and not the VOD Streams. How can my PHP script be improved my PHP script to it only gets the Live Streams?</p>
  
  <p>I could not find any XML value for this.</p>
  
  <pre><code>$hostname = "localhost"; 
  
  $xml_data=file_get_contents("http://$hostname:8086/connectioncounts"); 
  
    $doc = new DOMDocument(); 
    $doc-&gt;loadXML($xml_data); 
  
    $wms = $doc-&gt;getElementsByTagName('WowzaStreamingEngine'); 
    print_r($wms);
    $wmstotalactive = $wms-&gt;item(0)-&gt;getElementsByTagName("ConnectionsCurrent")-&gt;item(0)-&gt;nodeValue; 
    $wmstotaloutbytes = $wms-&gt;item(0)-&gt;getElementsByTagName("MessagesOutBytesRate")-&gt;item(0)-&gt;nodeValue; 
    $wmstotaloutbits = $wmstotaloutbytes * '8'; 
  
  echo "&lt;center&gt;&lt;b&gt;Hostname:&lt;/b&gt; $hostname&lt;br&gt;&lt;/center&gt;&lt;hr&gt; &lt;b&gt;Server Total Active Connections:&lt;/b&gt; $wmstotalactive&lt;br&gt; &lt;b&gt;Total Outbo 
  and bitrate:&lt;/b&gt;  $wmstotaloutbits&lt;br&gt;&lt;hr&gt;"; 
  
    $wmsapp = $doc-&gt;getElementsByTagName('Application'); 
    $wmscnt = $wmsapp-&gt;length; 
  
  echo "&lt;center&gt;Applications&lt;/center&gt;"; 
  
  for ($idx = 0; $idx &lt; $wmscnt; $idx++) { 
    $appname = $wmsapp-&gt;item($idx)-&gt;getElementsByTagName("Name")-&gt;item(0)-&gt;nodeValue; 
    $appccount = $wmsapp-&gt;item($idx)-&gt;getElementsByTagName("ConnectionsCurrent")-&gt;item(0)-&gt;nodeValue; 
    $appoutbytes = $wmsapp-&gt;item($idx)-&gt;getElementsByTagName("MessagesOutBytesRate")-&gt;item(0)-&gt;nodeValue; 
    $appoutbits = $appoutbytes * '8'; 
  
    echo "&lt;hr&gt;&lt;b&gt;Application Name:&lt;/b&gt; $appname&lt;br&gt;&lt;b&gt; Active Connections:&lt;/b&gt; $appccount&lt;br&gt; &lt;b&gt;Application Bits Out:&lt;/b&gt; $appoutbits 
  &lt;br&gt;"; 
  } 
    echo "&lt;hr&gt;&lt;center&gt;Streams&lt;/center&gt;"; 
    $wmsast = $doc-&gt;getElementsByTagName('Stream'); 
    $wmsasct = $wmsast-&gt;length; 
  
  for ($sidx = 0; $sidx &lt; $wmsasct; $sidx++) { 
    $strname = $wmsast-&gt;item($sidx)-&gt;getElementsByTagName("Name")-&gt;item(0)-&gt;nodeValue; 
    $strctot = $wmsast-&gt;item($sidx)-&gt;getElementsByTagName("SessionsTotal")-&gt;item(0)-&gt;nodeValue; 
  
    echo "&lt;hr&gt;&lt;b&gt;Stream URL:&lt;/b&gt; $strname &lt;br&gt; &lt;b&gt;Connections to Stream:&lt;/b&gt; $strctot&lt;br&gt;"
  
  } 
  </code></pre>