473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Character Entity References & DOM


The following statement does not yield what I expect it to:

var txtNode = document.createTextNode("ESI−");

txtNode holds a value of "ESI−" instead of "ESI-" where '-' is the
character entity reference for the minus sign, that I expect.

I have tried other variations. I am working with Mozilla and IE because I
want to make NO use of extensions/browser-dependent code, and both (try to)
implement the DOM to varying degrees.

Searches of keyword sets:

createTextNode "character entity" HTML

and the permutations have not been helpful.

Does anyone know the secret?
Jul 23 '05 #1
1 1828
On Wed, 06 Oct 2004 18:01:51 GMT, User Axes Dean Eyed
<Re**************@Assimilated.B.org> wrote:
The following statement does not yield what I expect it to:

var txtNode = document.createTextNode("ESI&minus;");

txtNode holds a value of "ESI&minus;" instead of "ESI-" where '-' is the
character entity reference for the minus sign, that I expect.


This is discussed in the Specification:

<URL:http://www.w3.org/TR/DOM-Level-2-Core/introduction.html#ID-E7C30824>

As the extended intefaces mentioned in that section are directed at XML
documents, I don't think it's possible to include an entity reference in
the way you want. Your best bet is to look up the numeric values of the
entities (<URL:http://www.w3.org/TR/html4/sgml/entities.html>) and use
JavaScript string escape sequences. Numeric codes below 255 can be
specifed in hexadecimal using \xNN. Other characters must use the Unicode
hexadecimal sequence, \uNNNN. These are provided in the reference above
within the entity comments (look for U+NNNN). Your code above would be:

var txtNode = document.createTextNode("ESI\u2212");

[snip]

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Ian | last post by:
I'm using the following meta tag with my documents: <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii" /> and yet using character entities like &rsquo; and &mdash; It...
50
by: The Bicycling Guitarist | last post by:
A browser conforming to HTML 4.0 is required to recognize &#number; notations. If I use XHTML 1.0 and charset UTF-8 though, does &eacute; have as much support as é ? Sometimes when I run...
40
by: Shmuel (Seymour J.) Metz | last post by:
I'd like to include some Hebrew names in a web page. HTML 4 doesn't appear to include character attributes for ISO-8859-8. I'd prefer avoiding numeric references, e.g.,...
11
by: BenI | last post by:
Hello, I have a XML file using Iso 8859-1 encoding. Every time when I try to put & character as Tag's value like <tag>This is & character</tag> Exception is shown in my application. I use...
44
by: Kulgan | last post by:
Hi I am struggling to find definitive information on how IE 5.5, 6 and 7 handle character input (I am happy with the display of text). I have two main questions: 1. Does IE automaticall...
18
by: R. P. | last post by:
I wonder how to indicate in a stylesheet that character entities in an element are not to be transformed as would be the case in XML-to-XML transforms. I want to keep those &amp; &quot; and other character...
3
by: bsagert | last post by:
Some web feeds use decimal character entities that seem to confuse Python (or me). For example, the string "doesn't" may be coded as "doesn’t" which should produce a right leaning apostrophe....
3
by: jake | last post by:
I am new to xml. I have a routine that parses xml files using a regular XmlReader class. Unfortunately, the XmlReader chokes (throws an exception) on character codes such as "&Eacute;". I...
7
by: tempest | last post by:
Hi all. This is a rather long posting but I have some questions concerning the usage of character entities in XML documents and PCI security compliance. The company I work for is using a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.