Home > Articles

  • Print
  • + Share This

Named Character Entities

WML named and numeric character entities are useful when you need to display a WML reserved character. For example, the less-than character "<" is normally interpreted as an element start character. However, named entities provide a readable way to insert reserved characters in display text. Most of the WML entities are defined in the XML specifications and include these:

  • Ampersand (&):
  • Apostrophe (`):
  • Greater than (>):
  • Less than (<):
  • Nonbreaking space ( ):
  • Quotation mark ("):
  • Soft hyphen (-):

Recall from our discussion of variables that the dollar sign is used to reference a variable value. To display a dollar sign in WML text, you must use two consecutive dollar signs. For example: The cost is $$ $price will display as The cost is $100.00 when the variable price has the value 100.00.

Figure 5 shows how named character entities can be used.

. . .
  Cream content in homogenized milk must&nbsp;be &gt;= 3%.
  Temperatures of cheese &amp; milk should be &lt; 5 degrees.
. . .

Figure 5 Named character entities

The >, &, and < characters are used to reduce text size. The &nbsp; nonbreaking space is used to ensure that the words must and be are kept on the same line.

Note that the named character entities can also be expressed as hexadecimal or decimal numbers. For example, the named character entity `quot' could also be written as &#34; or &#x22;.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.