troubleshooting Question

ASP and Looping Thru a XML Document

Avatar of Overthere
Overthere asked on
4 Comments1 Solution182 ViewsLast Modified:
I have a xml document that I wish to loop thru and extract data. The page is working fine but I think it could be coded much efficiently.
In my original coding vIndex was increment and I had a loop etc. It's just messy.
I have posted my new coding and old coding.
The new coding gives me o  from objNodeList.length statement.
What am I doing wrong??
new coding below
	set objNodeList = xdDoc.getElementsByTagName("SERVICEPROVIDER")	
	response.write "<BR>" & objNodeList.length
	if xdDoc.parseError = 0 then
	  if objNodeList.length > 0 then
	     for each x in objNodeList
		     response.write "<BR> inside for/next"
	             vprovider = x.getattribute("SERVICEPROVIDERNAME")
                     vbegdate = x.getattribute("STARTDATE")
                    venddate = x.getattribute("ENDDATE")
	    	     response.write "<BR>Provider is: " & vprovider & "   Startdate: " & vbegdate & "  Ending Date: " & venddate               
	   end if
        ' display error message
    end if 	 

And this is old coding and was how I was doing looping but messy - incrementing vIndex
	      wrkstartdate = xdDoc.selectSingleNode("SERVICECARD/SERVICEINFO/SERVICEPROVIDERLIST/SERVICEPROVIDER[" & vIndex & "]/STARTDATE").text
             wrkenddate=  xdDoc.selectSingleNode("SERVICECARD/SERVICEINFO/SERVICEPROVIDERLIST/SERVICEPROVIDER[" & vIndex & "]/ENDDATE").text
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros