Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getElementByTagName object required error

Status
Not open for further replies.

kdelacruz

Technical User
Oct 7, 2002
25
0
0
ES
Hello!
In my asp code, I have loaded an xml file and am cycling thru the childnodes.
I have a For ...Next loop that goes thru and (for now) should display each item.
It works fine when I reference each item using a static number:
Code:
response.write objXML.getElementsByTagName("presdesc").item(0).text

but when I try to reference items using a variable, like this:

Code:
For intCounter = 0 to (objXML.documentElement.childNodes.length + 1)
	response.write objXML.getElementsByTagName("presdesc").item(intCounter).text
	intCounter = intCounter + 1
Next

I get this error in my browser (IE 6):
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[object]'


Can anyone tell me what I'm doing wrong?

Thanks!
 
I forgot to mention that the problem only seems to occur when I use the counter variable. If I create another variable and set it to a static integer:
Code:
intMyInt = 3
response.write objXML.getElementsByTagName("presdesc").item(intMyInt).text
it works fine!

This is driving me crazy! I even tried converting my counter variable to an integer, and to a string, with no luck. I also tried
Code:
intMyInt = intCounter
and got the same error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top