How to use Entity in XML
In this articles i am going to explain about Entity in XML
Definition
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: "
- < is a less-than symbol: <
- > 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 WAR "War">
<!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 "ÉWrox" >
<!ENTITY rights "All rights reserved" >
<!ENTITY book "Black: Apress, © 1947 %pub;.
&rights;">
|
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