I would like to reiterate that this does not work when compiled with versions of libxml lower than 20620. I found that it just presents a blank page.
<?php $string = $reader->readString(); ?>
I worked around this issue by adding the following helper function:
<?php
function read_string($reader) {
$node = $reader->expand();
return $node->textContent;
}
?>
And then using:
<?php $string = read_string($reader); ?>