February 22, 2002 - DOM Tree Representation of Entity References
February 22, 2002 DOM Tree Representation of Entity References Tips: February 2002
Yehuda Shiran, Ph.D.
|
Let's look at an example. Here is the description
element from our mydvd
example:
<description>Sales Report for January, February,
and <&month;> of 2001</description>
The DOM tree splits the text of this description
element to three nodes:
"Sales Report for January, February, and <"
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.