Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Object doesn't support this property of method for getElementsByTagName

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hide Table in merge 3 30
Make Session back to empty 9 30
Running a javascript project in WebStorm 2 24
How to control cache of some js files ? 7 38
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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

808 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