XSD requiring a specific root element exist in an XML document?
问题 I want to validate a XML file and to make sure it has a root element called speak like this: <speak> <!--other node here...--> </speak> the speak element must exist in XML and must appears only once. I try to add code below in my XSD file: <xsd:element name="speak" type="speak" minOccurs="1" maxOccurs="1"/> But it does not work. 回答1: In the schema itself, you can't put a constraint on what the root element must be. (That's by design, though not everyone thinks it's a good design.) Any global