spacer
Yehuda Shiran February 22, 2002
DOM Tree Representation of Entity References
Tips: February 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

The DOM tree creates a child for every entity reference. An interesting situation arises when an entity reference is embedded inside an XML string. Will the entity reference be a child of the whole XML string?

Let's look at an example. Here is the description element from our mydvd example:

<description>Sales Report for January, February, 
  and &lt;&month;&gt; of 2001</description>
The DOM tree splits the text of this description element to three nodes:

  • Up to the entity reference: "Sales Report for January, February, and &lt;"
  • Entity reference: April
  • Trail:
    "< of 2001"

Let's show that indeed this is the case. First, we find the list of description objects:

objNodeList = xmlDoc.getElementsByTagName("description");
Our description is the first and only instance, so its index is 0. The following script prints the text values of description's three children:

alert(objNodeList(0).childNodes(0).text);
alert(objNodeList(0).childNodes(1).text);
alert(objNodeList(0).childNodes(2).text);
When running this script, you should get the three strings above.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint