Predefined Entities in XML and HTML

Home » xml » Predefined Entities in XML and HTML
xml No Comments

XML has special entities that can be used to enter text into XML documents without typing it all out. There are many letter and symbols that can be inserted into bot XML and HTML documents by using entities. In XML, however, there are only five predefined entities.

Five Special Symbols

Below are the five special symbols you can enter into your document and how they can be entered:

  • & to create an ampersand character ( & )
  • < to create a less than sign ( < )
  • > to create a greater than sign ( > )
  • " to create a double quotation mark ( ” )
  • ' to create a single quotation mark or apostrophe ( ‘ )

Why we need these symbols

These entities exist in XML because each of these characters have a specific meaning, the less than character (<) has a special meaning - if it is inserted within the text value of an element or attribute, the XML preprocessor would think you are starting a new element and your document is ... well ... useless.

You can use the smaller than (<) or ampersand (&) anywhere in your XML document, except to begin a tag or an entity. If you need to use one of thee characters within the text value of an element or attribute you must use one of the predefined entities.

LEAVE A COMMENT