/**
* @param string $xml
* @return object
*/
function unmarshalFromString($xml)
{
$xml = trim((string) $xml);
$reader = new XMLReader();
if (!$reader->XML($xml)) {
throw MarshallerException::couldNotReadXml($xml);
}
// Position at first detected element
while ($reader->read() && $reader->nodeType !== XMLReader::ELEMENT) {
}
$mappedObject = $this->doUnmarshal($reader);
$reader->close();
return $mappedObject;
}