Parses XML search results received from jobs.

Results are obtained by iterating over an instance of this class using a foreach loop. Each result can be a Splunk_ResultsFieldOrder, a Splunk_ResultsMessage, an associative array, or potentially instances of other classes in the future.

If the result is an associative array, it maps each field name to either a single value or an array of values.

 $resultsReader = new Splunk_ResultsReader(...);
 foreach ($resultsReader as $result)
 {
     if ($result instanceof Splunk_ResultsFieldOrder)
     {
         // Process the field order
         print "FIELDS: " . implode(',', $result->getFieldNames()) . "\r\n";
     }
     else if ($result instanceof Splunk_ResultsMessage)
     {
         // Process a message
         print "[{$result->getType()}] {$result->getText()}\r\n";
     }
     else if (is_array($result))
     {
         // Process a row
         print "{\r\n";
         foreach ($result as $key => $valueOrValues)
         {
             if (is_array($valueOrValues))
             {
                 $values = $valueOrValues;
                 $valuesString = implode(',', $values);
                 print "  {$key} => [{$valuesString}]\r\n";
             }
             else
             {
                 $value = $valueOrValues;
                 print "  {$key} => {$value}\r\n";
             }
         }
         print "}\r\n";
     }
     else
     {
         // Ignore unknown result type
     }
 }
package Splunk

 Methods

Constructs a new search results string or stream.

__construct(string | resource $streamOrXmlString) 

Parameters

$streamOrXmlString

stringresource

A string or stream containing results obtained from the {@link Splunk_Job::getResultsPage()} method.

Returns the current element of this iterator.

current() : \Splunk_ResultsFieldOrder | \Splunk_ResultsMessage | array | mixed

Returns

\Splunk_ResultsFieldOrder\Splunk_ResultsMessagearraymixedThe current element of this iterator.

Advances this iterator to the next element.

next() 

Returns a value that indicates whether there are any more elements in the stream.

valid() : boolean

Returns

booleanWhether there are any more elements.

Reads metadata from the stream.

readMeta() 

Returns the next element in the stream.

readNextElement() 

Returns search results from the stream.

readResult() 

 Properties

 

$atStart 
 

$currentElement 
 

$emptyXml 
 

$xmlReader