public function parse($input, array
$options = array
()) { $this->errors = array
();
$options =
array_merge($this->defaultOptions,
$options);
$events =
new DOMTreeBuilder(false,
$options);
$scanner =
new Scanner($input, !
empty($options['encoding'
]) ?
$options['encoding'
] : 'UTF-8'
);
$parser =
new Tokenizer($scanner,
$events, !
empty($options['xmlNamespaces'
]) ? Tokenizer::CONFORMANT_XML : Tokenizer::CONFORMANT_HTML
);
$parser->
parse();
$this->errors =
$events->
getErrors();
return $events->
document();
} /**
* Parse an input stream where the stream is a fragment.
*
* Lower-level loading function. This requires an input stream instead
* of a string, file, or resource.
*
* @param string $input The input data to parse in the form of a string.
* @param array $options An array of options.
*
* @return \DOMDocumentFragment
*/