Explain the document element.

Q3. Explain the document element.

Ans. The root element is also known as the document element that contains all other elements in XML document. It means that all the elements are nested within the root element. In other words, you can say that the root element is the parent element for all other elements. An XML document must contain at least one element that will be a parent for all the other elements.

 

Consider the following example of a root element or document element:

<Employees>

<employee>

<FirstName>Ambrish</FirstName>

<LastName>Kohli</LastName>

</employee>

<employee>

<FirstName>Rahul</FirstName>

<LastName>Sharma</LastName>

</employee>

</Employees>

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: