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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required Error on a NodeList

Status
Not open for further replies.

mskikic

Programmer
Nov 20, 2001
2
US
Hello all,

I am having a problem with a NodeList object. even though it may at first seem like a fairly simple problem, I have found related articles in other forums with the same exact question, but never a definite solution. I am posting to this forum now hoping someone could help me.

My code is as follows:

[tt]
Function FindDistrictNode(strDistrict)

Dim objAttrList, objAttr, tempNode, strAttribute, objNodeList, strTemp
Set objNodeList = objXml.getElementsByTagName("district")
tempNode = 0

Do while not strAttribute = strDistrict or tempNode = objNodeList.length

set objAttrList = objNodeList.item(tempNode).attributes '<---
for each objAttr in objAttrList
if objAttr.name = &quot;district&quot; then
strAttribute = objAttr.value
End iF
Next

tempNode = tempNode + 1
set objAttrList = nothing
Loop


Set objDis = objNodeList.item(tempNode-1)

End Function
[/tt]

I've reached this code after multiple version that I've tried and none worked. I am obtaining the error '800a01a8', Object required: &quot;objNodeList.item&quot; for the line with the arrow, above.
If anyone knows the possible reasons, I would greatly appreciate any input.
Thanks in Advance.

Mili Skikic
 
Never mind, everybody !

I feel pretty stupid, but if you take a look at my iteration, you will see that I have not defined the limit of the loop correctly!!!
The loop is reaching the end of the collection and since it's a &quot;do-while&quot; it is doing it once again, and finding the 'tempnode' empty.
It should be something like:
i = objNodeList.length - 1
do while not tempnode = i-1
Or use simply &quot;while&quot; loop.

Apologies.

Mili Skikic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top