Been looking at a tutorial and it has the following xml and xsd.:
Wha
Yes, you always have to have a root node. However, you can have a file that holds an XML document fragment that is imported into another file as a parsed entity. All the including file needs to do is have a declaration like this in its DTD:
<!ENTITY SomeName SYSTEM "/path/to/file.xml">
Then it can just wrap it up like this:
<SomeOuterTag>
&SomeName;
</SomeOuterTag>
Root node is mandatory. It's also referred to as "Document Element" in W3C's nomenclature.
Definition: There is exactly one element, called the root, or document element, no part of which appears in the content of any other element (reference: section 2.1 of W3C XML specs)
Yes, you are required to have one, and only one root node.
from the XML specification at http://www.w3.org/TR/REC-xml/ (fifth edition) chapter 2
This says
"Each XML document has both a logical and a physical structure. Physically, the document is composed of units called entities. An entity may refer to other entities to cause their inclusion in the document. A document begins in a "root" or document entity."
"[Definition: There is exactly one element, called the root, or document element, no part of which appears in the content of any other element.] For all other elements, if the start-tag is in the content of another element, the end-tag is in the content of the same element. More simply stated, the elements, delimited by start- and end-tags, nest properly within each other."
So basically yes, you always need one root element.
From the brief description of XML at Wikipedia, which summarizes several well-formedness rules from the official XML spec:
There is a single "root" element which contains all the other elements.