XML Attributes Elements

What are XML attributes and elements? Explain with an example?

Questions by Depthi

  
Showing Answers 1 - 2 of 2 Answers

MR

  • Jul 13th, 2011
 

Consider the following XML code snippet:
is the element, and first-name is the attribute.

Code
  1. <name first-name="Raj">Kumar</name>

  2.  

  Was this answer useful?  Yes

Manasa

  • Oct 13th, 2011
 

Code
  1. <person sex="female">

  2.   <firstname>Anna</firstname>

  3.   <lastname>Smith</lastname>

  4. </person>

  5.  

  6. <person>

  7.   <sex>female</sex>

  8.   <firstname>Anna</firstname>

  9.   <lastname>Smith</lastname>

  10. </person>

  11.  


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

  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