define XML Elements, Attributes with example?

define XML Elements, Attributes with example?

There are no rules about when to use attributes or when to use elements.

For Example:

1. <person sex=\"female\">

     <firstname>Anna</firstname>

       <lastname>Smith</lastname>

   </person>

2. <person>

     <sex>female</sex>

      <firstname>Anna</firstname>

     <lastname>Smith</lastname>

   </person>


In the first example sex is an attribute. In the last, sex is an element. Both examples provide the same information.



By:Aditya
Date:2027-10-10 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related XML Subjective Links

XML Subjective interview questions and answers for experienced and fresher