//readXml.htm
02 |
03 | <html> |
04 |
05 | <head> |
06 |
07 | <title>E4X</title> |
08 |
09 | <script type= "text/javascript" > |
10 | var xmlDoc; |
11 | function clickHandler() |
12 | { |
13 | if (window.ActiveXObject) |
14 | { |
15 | xmlDoc = new ActiveXObject( "MSXML.DOMDocument" ); |
16 | if (xmlDoc == null ) |
17 | { |
18 | window.alert( "MSXML.DOMDocument isn't installed." ); |
19 | } |
20 | else |
21 | { |
22 | xmlDoc.async= false ; |
23 | xmlDoc.load( "note.xml" ); |
24 | document.write(xmlDoc.getElementsByTagName( "body" )[0].firstChild.nodeValue); |
25 | } |
26 | } |
27 | // code for Mozilla, Firefox, etc. |
28 | else if (document.implementation && document.implementation.createDocument) |
29 | { |
30 | xmlDoc= document.implementation.createDocument( "" , "" , null ) |
31 | xmlDoc.load( "note.xml" ); |
32 | xmlDoc.onload= function () //anonymous function |
33 | { |
34 | document.write(xmlDoc.getElementsByTagName( "body" )[0].firstChild.nodeValue); |
35 | } |
36 | } |
37 | } |
38 |
39 | </script> |
40 |
41 | </head> |
42 |
43 | <body> |
44 | <span>nothing</span> |
45 | <button onclick= "javascript:clickHandler()" />hello, world. |
46 |
47 | </body> |
48 |
49 | </html> |