Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xmldom Im lost

Status
Not open for further replies.

GaryC123

Programmer
Sep 10, 2002
1,041
NO
I have this script taken from w3schools. But when i run it locally I get an error on line 9 - Object Required. What am I doing wrong?

<html>
<head>
<script type=&quot;text/javascript&quot; for=&quot;window&quot; event=&quot;onload&quot;>
var xmlDoc=new ActiveXObject(&quot;Microsoft.XMLDOM&quot;)
xmlDoc.async=&quot;false&quot;
xmlDoc.load(&quot;note.xml&quot;)

'line 9
nodes=xmlDoc.documentElement.childNodes
a1.innerText=nodes.item(0).text
a2.innerText=nodes.item(1).text
a3.innerText=nodes.item(2).text
a4.innerText=nodes.item(3).text

</script>
</head>

<body bgcolor=&quot;yellow&quot;>

<h1>W3Schools Internal Note</h1>

<b>To:</b>
<span id=&quot;a1&quot;></span>
<br />

<b>From:</b>
<span id=&quot;a2&quot;></span>
<hr />

<b><span id=&quot;a3&quot;></span></b>

<hr />
<span id=&quot;a4&quot;></span>

</body>
</html>



 
Code:
xmlDoc.load(&quot;note.xml&quot;)

Your not checking the return value so if load fails then the .documentElement property will be &quot;null&quot;

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top