在PHP中解析Lucene / SOLR debug.explain.structured xml输出

The default "human readable" formatting of solr's debug-mode explain feature is completely useless. You can get some structured xml output by passing debug.explain.structured=true.

However the xml it generates isn't really usable either and I need to be able to use this debugging information elsewhere in my code.

Before I re-invent the wheel, I have two questions:

1) Does anyone know of an existing PHP class (or function) that will parse this xml and turn it into a useful object? (googling didn't turn up anything obvious)

2) For those familiar with SOLR's debug mode, is there a better way to approach this than parsing the debug.explain.structured xml?

(I'm Using SOLR 3.6)

I am doing this using the solr-php-client. I do use a regular expression to parse out a specific value, but it's easy to access the debug explanation.

As an example, here is how I extract the coord value from the debug explanation:

$client = new Apache_Solr_Service($hostname, $port, $url);
$response = $client->search($q, $offset, $limit, $parameters);

$debug = reset($response['debug']['explain']); // get the first explanation
if (preg_match('#([\d\.]+) = coord\((\d+)/(\d+)\)#m', $debug, $matches)) {
    $coord = floatval($matches[1]);
    $overlap = intval($matches[2]); // the number of matching keywords
    $max_overlap = intval($matches[3]); // the total number of keywords
}

i am having the same problem and stared a github project for parsing the solr explain into an object structure. With this library it is possible to calculate the impact of a certain field from the explain output:

https://github.com/timoschmidt/php-solr-explain