Solved

Object doesn't support this property of method for getElementsByTagName

Posted on 2004-04-16
3
1,893 Views
Last Modified: 2009-07-29
I have this code within the <head> tag of my html page:

<script language="JavaScript">

      var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
      xmlDoc = xmlDoc.load("test.xml");
      var testLoad = xmlDoc.getElementsByTagName("state");
      
</script>


I'm consistently getting a Object doesn't support this property or method error indicating the error is with var testLoad = xmlDoc.getElementsByTagName("state"); I tried it with the full path to the xml document and got the same results. I have MSXML 4.0 sp2 installed on my computer.

Why am I getting this error?
0
Comment
Question by:MovnOn
  • 2
3 Comments
 
LVL 25

Expert Comment

by:devic
ID: 10845702
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmlDoc.load("test.xml");
var testLoad = xmlDoc.getElementsByTagName("state");
alert(testLoad.item(0).text);
0
 
LVL 25

Accepted Solution

by:
devic earned 50 total points
ID: 10845753
the problem was, that you "killed" your object xmlDoc.

>>>xmlDoc = xmlDoc.load("test.xml");
after this line xmlDoc is not xmlDoc object, but a boolean.


you can debug your code so:
=========================
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
alert(typeof(xmlDoc))

xmlDoc=xmlDoc.load("test.xml");
alert(typeof(xmlDoc))

alert(xmlDoc);
0
 

Author Comment

by:MovnOn
ID: 10846392
That explains it. Thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now