Root element in XML

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
 
D

Dejy

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
 
J

Jeroen Mostert

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top