What are the rules to be followed in the usage of closing tag in XML?

Questions by blenda   answers by blenda

Showing Answers 1 - 3 of 3 Answers

One big difference between XML and HTML is that an XML document is always constrained to be well formed. There are several rules that determine when a document is well formed, but one of the most important is that every tag has a closing tag. So, in XML, the </to> tag is not optional. The <to> element is never terminated by any tag other than </to>.

Sometimes, though, it makes sense to have a tag that stands by itself. For example, you might want to add a tag that flags the message as important: <flag/>.

This kind of tag does not enclose any content, so it's known as an empty tag. You create an empty tag by ending it with /> instead of >. For example, the following message contains an empty flag tag:

<message to="you@yourAddress.com" from="me@myAddress.com" 
    subject="XML Is Really Cool">
  <flag/>
  <text>
    How many ways is XML cool? Let me count the ways...
  </text>
</message>

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions