By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,630 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,630 IT Pros & Developers. It's quick & easy.

DOMDocument.getElementsByTagName stopped working in IE

P: 2
Hello everyone!

I used the code to get all elements with same tag from XML returned from the server:
Expand|Select|Wrap|Line Numbers
  1. persons = xmlhttp.responseXML.getElementsByTagName("person");
It had worked perfect, but from one moment I started receiving an error message Object doesn't support this property or method in IE. In Opera and FF it still works fine.

I tried on IE 7 and IE 6 - the problem stays.

Then I tried to make some workaround for this issue and I wrote the following:

Expand|Select|Wrap|Line Numbers
  1. var xmlObj = new ActiveXObject("Msxml2.DOMDocument");
  2. xmlObj.loadXML('<?xml version="1.0" encoding="utf-8"?><persons><person name="Huy Morzhovy" e-mail="" language="en" /></persons>');
  3. persons = xmlObj.getElementsByTagName("person"); 
And I'm still receiving Object doesn't support this property or method for xmlObj.getElementsByTagName("person") in IE!

I tried to google something about this problem but I failed.

Does anybody knows something about this? Maybe it's related somehow to latest changes which were installed by Windows Update on my PC...

I'll be appreciated for any help on this.
Thanks in advance.
Jan 10 '08 #1
Share this Question
Share on Google+
4 Replies

P: 2
Ok, finally I found a bug.
It happened because variable persons was not correctly described.
Just adding
Expand|Select|Wrap|Line Numbers
  1. var persons;
before the code above solved the problem.

But I still have questions:

1. How and why did it work before (and I'm pretty sure it worked)?
2. Why did I get false for typeof(xmlhttp.responseXML.getElementsByTagName)== 'function' when persons wasn't described?
Jan 10 '08 #2

Expert Mod 15k+
P: 16,027
If you post the rest of your code, we might have a better idea where the problem was.
Jan 11 '08 #3

P: 1
Thanks! This happened to me too, I wrote the line for XML Ajax response

response = t.responseXML;
var list = response.getElementsByTagName('row');
Nov 17 '08 #4

P: 1
i had the same problem. i think it's because you have a control with the same id as what you're trying to assign.

so if you have

<div id="person"></div>

then IE gives an error when you say person=something;

when you say 'var person' it makes the variable local....
Feb 19 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.