Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Object doesn't support this property of method for getElementsByTagName

Posted on 2004-04-16
3
Medium Priority
?
1,907 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
[X]
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
  • 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

604 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