Root Element − An XML document can have only one root element. The Following example shows correct nested tags − The Following example shows incorrect nested tags − i.e., an end tag of an element must have the same name as that of the most recent unmatched start tag. Nesting of Elements − An XML-element can contain multiple XML-elements as its children, but the children elements must not overlap. The names of XML-elements are enclosed in triangular brackets as shown below −Įlement Syntax − Each XML-element needs to be closed either with start or with end elements as shown below − The XML declaration strictly needs be the first statement in the XML document.Īn HTTP protocol can override the value of encoding that you put in the XML declaration.Īn XML file is structured by several XML-elements, also called XML-nodes or XML-tags. If document contains XML declaration, then it strictly needs to be the first statement of the XML document. The XML declaration is case sensitive and must begin with " " where " xml" is written in lower-case. Where version is the XML version and encoding specifies the character encoding used in the document. The XML document can optionally have an XML declaration. Let us see each component of the above diagram in detail. The following diagram depicts the syntax rules to write different types of markup and text in an XML document. The text, or the character data, Tutorials Point and (040) 123-4567. You can notice there are two kinds of information in the above example − In this chapter, we will discuss the simple syntax rules to write an XML document.