protected function loadXMLString($xmlString)
{
$document = new DOMDocument();
libxml_use_internal_errors(true);
libxml_clear_errors();
// Options:
// - substitute entities
// - disable network access
// - relax parser limits for document size/complexity
$success = $document->loadXML($xmlString, LIBXML_NOENT | LIBXML_NONET | LIBXML_PARSEHUGE);
if (!$success) {
$messages = array();
foreach (libxml_get_errors() as $error) {
$messages[] = trim($error->message);
}
throw new InvalidArgumentException('$inputValue', 'Could not create XML document: ' . implode("\n", $messages));
}
return $document;
}