Solved

Object doesn't support this property of method for getElementsByTagName

Posted on 2004-04-16
3
1,894 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

867 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

22 Experts available now in Live!

Get 1:1 Help Now