Avatar of Overthere
Overthere
 asked on

ASP and Extracting XML

I have a snippet of coding which worked fine in my test page. Extracted everything I asked for.
I inserted it into my program and it does not extract my data
All of my other routines work well.
I did not receive any script errors, nothing in debugger, nothing in IE developer tools. Did not even write out my response.write statement.
There is nothing that should have caused this since my test page loads the same xml file.
I realize that saying I took it from my test page and inserted it into my going-to-be-production is subject to well, comments that there must be something transpiring that is causing the problem. But there isn't.
I have posted my snippet of coding and an example of the xml I am extracting. The only thing I can think of is that there are two sections that have passengers - I will post what that looks. I thought maybe it was getting confused. But that could not be because if it was, then my test page would not have worked - they are both using the same xml file.
All I receive is the "Passengers Next" and it just skips right over it the extraction rtn and hits the response.end line.
Any help appreciated.
Below is the coding from my test page and it works just fine. I get the first and last name for each one.
'extract passengers only if BID=NEW
        if (Session("BID") = "NEW") and  (xdDoc.parseError = 0) then
	        Set colNodes = xdDoc.selectNodes("//PASSENGERLIST/PASSENGER") 
	 	    'if xdDoc.parseError = 0 then
	  	    'extract item info
			 for each objItem in colNodes
			    vlname = objItem.selectSingleNode("LASTNAME").text
			    vfname = objItem.selectSingleNode("FIRSTNAME").text
			    response.write "<BR>PASSENGER:" & vfname & " " & vlname
			 next	
			 set colNodes = nothing
	         'end if
		else
        ' display error message
        end if 	 

Open in new window

This is what I have in nearly-to-go-production page - you will notice I tried several definitions
 response.write "<BR>PASSENGERS NEXT"
 		if xdDoc.parseError = 0 then
            if (Session("BID") = "NEW") then
			    vcounter = 1
	                 ' Set colNodes = xdDoc.selectNodes("//PASSENGERLIST/PASSENGER") 
			  ' Set colChildNodes = xdDoc.selectNodes("SERVICECARD/SERVICE/PASSENGERLIST/PASSENGER")
			    Set colChildNodes = xdDoc.selectNodes("SERVICECARD/SERVICE/PASSENGERLIST")
	  	        'extract item info
			    for each objItem in colChildNodes
		           response.write "INSIDE PASSENGERS LOOP<BR>"
			       vlname = objItem.selectSingleNode("LASTNAME").text
			       vfname = objItem.selectSingleNode("FIRSTNAME").text
			       response.write "<BR>PASSENGER:" & vfname & " " & vlname
				  ' vpassid = MkPassengers(vcounter,vlname,vfname)
				   vcounter = (vcounter + 1)
			  next	
			 set colChildNodes = nothing
		    end if
        end if 	

response.end

Open in new window


this is what the xml section looks like:
<PASSENGERLIST>
      <PASSENGER>
        <LASTNAME>Rustler</LASTNAME>
        <FIRSTNAME>Ted</FIRSTNAME>
        </PASSENGER>
       <PASSENGER>
        <LASTNAME>Johnston</LASTNAME>
        <FIRSTNAME>Hartley</FIRSTNAME>
        </PASSENGER>
     </PASSENGERLIST>

Open in new window

ASPXML

Avatar of undefined
Last Comment
zc2

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
zc2

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Overthere

ASKER
Thank you for responding....Will do...will post results in awhile...
Overthere

ASKER
Thank you! I found it and fixed it! Thank you for the tip on the parse error and good reference link. Can you recommend a really good book on xml? Can either be electronic or paperback...
Overthere

ASKER
Thank you ! your help is appreciated :}
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
zc2

You are welcome. I used a book by Michael Kay https://www.goodreads.com/author/list/255136.Michael_Kay
Overthere

ASKER
Thank you - is it the one where several other authors are included - version 2.0 ? I hope they have a e-book!
zc2

No, actually I read the one about XSLT, but I like how Michael explain things, so other might be good too.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.