Retrieves an element from the document and returns it if it is non-null and has the expected type. Otherwise an error is thrown.

InvalidOperationError When the document element has an unexpected type.

UnexpectedNilError When the the document element is null.