ProAnswers.org

What is entity referencing in XML?

There are two additional ways in XML documents to reference characters:

		a numeric character reference refers to a character
	
		an entity reference refers to a series of characters


	Where entities are used, the referenced characters appear.


Numeric character references:

A numeric character reference can be specified in two formats:
nnnn; or hhhh;
where the n decimal digits or the h hexadecimal characters identify the Unicode character code of the referenced character.

Entity references:

An entity reference is an alternative name for a series of characters. You can use an entity in the &name; format, where name is the name of the entity. There are some predefined entities in XML, furthermore you can declare entities in a DTD (Document Type Definition).


	Predefined entities:
The following predefined entities exist in XML:

	
		
			
				Entity name
			
				Character
			
				Decimal reference
			
				Hexadecimal reference
		
	
	
		
			
				quot
			
				"
			
				"
			
				"
		
		
			
				amp
			
				&
			
				&
			
				&
		
		
			
				apos
			
				'
			
				'
			
				'
		
		
			
				lt
			
				<
			
				<
			
				<
		
		
			
				gt
			
				>
			
				>
			
				>
		
	



Declaring entities:

You can declare entities in a DTD in the following format:

	
where name is the name of the entity and text is the referenced text that appears where the entity is used.