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

Blank value in a loop

Status
Not open for further replies.

huobaji

Technical User
Sep 20, 2010
23
US
I have a loop that loops through an XML when I come to the node1 there might be some that don't have a value (i). I tried to use a if statement to catch the value thats blank

XML info
ElementTag.Node1 well have node2 and node3 under it
then there would be another ElementTag.Node1 with node2 and node3 under it.

Is there a why to handle a empty value in a loop

I get this error
Microsoft VBScript runtime error '800a01a8'

Object required: 'item(...)'

/XML/showxml2.asp, line 49



Dim Cyear
Dim Cnumber
Dim Ctitle


Set objLst1 = xml.getElementsByTagName("node1")
Set objLst2 = xml.getElementsByTagName("node2")
Set objLst3 = xml.getElementsByTagName("node3")


For i = 0 to (objLst.length - 1)

if objLst1.item(i).text = "" then
response.write hello
else
Cyear = objLst1.item(i).text
end if


Cnumber = objLst2.item(i).text
Ctitle = objLst3.item(i).text


Response.Write Cyear
Response.Write Cnumber
Response.Write Ctitle

Next

Set xml = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top