Solved

Object doesn't support this property of method for getElementsByTagName

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

803 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