Root element in XML

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!


I'm reading about XML and here they say something that you might know
something about.

They say
"Another requisite to the XML syntax is the inclusion of at least a single,
root element that encapsulates the nested elements within."

But this must be wrong as I have been told you can only have one and only
one single root element you can't have more then one.

Do you agree with me ?

//Tony
 
I think that "at least" means that a minimum XML document will contain a
root element, possibly with no inner elements, not that the document can
have one or more root element.

Denis
 
Tony said:
I'm reading about XML and here they say something that you might know
something about.

They say
"Another requisite to the XML syntax is the inclusion of at least a single,
root element that encapsulates the nested elements within."

But this must be wrong as I have been told you can only have one and only
one single root element you can't have more then one.
The sentence is confusing bordering on the ungrammatical, but the intent is
that, among other things (like processing instructions and nested elements)
an XML document must consist of at least one element, which is the root (and
there must be only a single element like that). It's just clumsily worded.

So yes, every XML document must have exactly one top-level element, which is
the root. The root can be an empty element, but you can't have an empty
document, and you can't have more than one root.
 
Back
Top