How to use Entity in XML

In this articles i am going to explain about Entity in XML
  • 1886


Entities in XML are used to represent specific characters, to re-use snippets of XML, to organize your documents into several files, and to make it easier to write DTDs. Here some entities are given below.

  • Character entities
  • Named entities
  • External entities
  • Parameter entities

All entities start with an ampersand (&) and end with a semicolon (;) character. The XML standard defines five standard entities that must be implemented by all XML parsers, regardless of what other entities they support:

  • ' is an apostrophe:
  • & is an ampersand: &
  • " is a quotation mark: "
  • &lt; is a less-than symbol: <
  • &gt; is a greater-than symbol: >

Entities are declared in the DTD, similar to elements and attributes.

Lets take an example of (general) Entity Declaration:

<!DOCTYPE Walking [
<!ENTITY R "Romance">
<!ENTITY COM "Comedy">
<!ENTITY SF "Science Fiction">
<!ENTITY ACT "Action">

Lets take an example of (general) Entity Declaration:

<!ENTITY % NAME "text that you want to be represented by the entity">
<!ENTITY % pub "&#xc9;Wrox" >
<!ENTITY rights "All rights reserved" >
<!ENTITY book "Black: Apress, &#xA9; 1947 %pub;. 

Further Readings

You may also read more about XML here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.