```ruby require "rexml" REXML::Document.new("") # no error REXML::Document.new("<?xml version='1.0'?>") # no error ``` https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-well-formed > [Definition: A textual object is a <b>well-formed</b> XML document if:] > > * Taken as a whole, it matches the production labeled <a href="https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-document">document</a>. > * It meets all the well-formedness constraints given in this specification. > * Each of the <a title="Text Entity" href="https://www.w3.org/TR/2006/REC-xml11-20060816/#dt-parsedent">parsed entities</a> which is referenced directly or indirectly within the document is <a title="Well-Formed" href="https://www.w3.org/TR/2006/REC-xml11-20060816/#dt-wellformed">well-formed</a>. > > Document > > [1] document ::= ( [prolog](https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-prolog) [element](https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-element) [Misc](https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-Misc)* ) - ( [Char](https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-Char)* [RestrictedChar](https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-RestrictedChar) [Char](https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-Char)* ) Should we report an error for no root input?
Activity
naitoh commentedon Sep 4, 2025
I think that if there is no root input, an error response should be returned.
kou commentedon Sep 5, 2025
OK. Let's validate it.
Added a check for the presence of the root tag
Added a check for the presence of the root tag
Added a check for the presence of the root tag
Added a check for the presence of the root tag
Reject no root element XML as an invalid XML (#291)