Extracting nodes  using classical ASP

Overthere
Overthere used Ask the Experts™
on
I have a snippet of coding - listed below - in which I am having problems figuring out how to pull a node.
I have also listed the XML document. I can loop very well to extract the <SERVICEPROVIDER> without a problem.
But I have not been able to construct my loop to extract the <ITEMAMOUNT>.
I am thinking I need to use xmlElementsByTagName(el, name, recursive = FALSE) - but I don't know.
There be many. It certainly does not like my inner loop where I am trying to extract the  <CATEGORY> and the  <QTY>and the       <DESCRIPTION>
My loop to process the <SERVICEPROVIDER>  works correctly.
But when I try to extract the nodes under <ITEMAMOUNTLIST>, it spits in my face :(   And probably rightfully so too.
I have also posted the xml document. And  snapshot of the error message.
Any help appreciated.

        set xdDoc = Server.CreateObject("MSXML2.DOMDocument.6.0")
	
	xdDoc.load "C:\VAXXML\SOMEVAX.XML"
		
       Set colChildNodes = xdDoc.selectNodes("///ITEMAMOUNT")
	
	'xmlElementsByTagName(el, name, recursive = FALSE)
	'xmlElementsByTagName("ITEMAMOUNT,"TRAVELCATEGORY")
	
	'extract item amounts
		if xdDoc.parseError = 0 then
	  	    'extract item info
			 for each objItem in colChildNodes
			    vqty = objItem.selectSingleNode("DESCRIPTION")
			    vremarks = objItem.selectSingleNode("REMARKS")
			    response.write "<BR>QTY:" & vqty & " " & vremarks
			 next
	    else
             ' display error  message
        end if 	 
	'end of extracting item info


	'extract service providers
      
      Set colNodes = xdDoc.selectNodes ("//SERVICEPROVIDER")

	if xdDoc.parseError = 0 then
	    for each objProvider in colNodes
		    'get provider info
		    response.write "<BR> inside for/next"
		   	vsegnbr = objProvider.selectSingleNode("PROVIDERTYPE").text
			if vsegnbr <> "5" then
   		    	vprovider = objProvider.selectSingleNode("SERVICEPROVIDERNAME").text
		    	vbegindate = objProvider.selectSingleNode("STARTDATE").text
		    	venddate = objProvider.selectSingleNode("ENDDATE").text
			    response.write "<BR>Provider Type is: " & vsegnbr
	    	    response.write "<BR>Provider is: " & vprovider
	    	    response.write "<BR>Begin date is: " & vbegindate
	    	    response.write "<BR>End date is: " & venddate
			end if
		next
	 else
        ' display error message
    end if 	 
	   
%>

Open in new window


Here is the xml document
<?xml version="1.0" encoding="utf-8"?>
<SERVICECARD>
  <DATEFORMAT>MMDDYYYY</DATEFORMAT>
  <RESCARDMOREFIELD>
    <UDIDNO />
    <UNITVALUE />
  </RESCARDMOREFIELD>
  <SERVICEINFO>
    <RESTYPE>7</RESTYPE>
    <ITEMAMOUNTLIST>
      <ITEMAMOUNT>
        <CATEGORY>0</CATEGORY>
        <QTY>1</QTY>
        <DESCRIPTION>CURB SERVICE</DESCRIPTION>
       </ITEMAMOUNT>
      <ITEMAMOUNT>
        <CATEGORY>5</CATEGORY>
        <QTY>1</QTY>
        <DESCRIPTION>2 FREE TICKETS FOR FREE PARKING</DESCRIPTION>
      </ITEMAMOUNT>
      <ITEMAMOUNT>
        <CATEGORY>5</CATEGORY>
        <QTY>1</QTY>
        <DESCRIPTION>INCLUDES 10 FREE MILES</DESCRIPTION>
      </ITEMAMOUNT>
      <SERVICEPROVIDER>
        <PROVIDERTYPE>0</PROVIDERTYPE>
        <SERVICEPROVIDERNAME>LOUD LARRY TAXIS</SERVICEPROVIDERNAME>
        <SERVICEPROVIDERCODE>LL</SERVICEPROVIDERCODE>
        <STARTDATE>07192017</STARTDATE>
        <ENDDATE>07192017</ENDDATE>
      </SERVICEPROVIDER>
      <SERVICEPROVIDER>
        <PROVIDERTYPE>0</PROVIDERTYPE>
        <SERVICEPROVIDERNAME>COOL LUKE RIDES</SERVICEPROVIDERNAME>
        <SERVICEPROVIDERCODE>CLR</SERVICEPROVIDERCODE>
        <STARTDATE>07232017</STARTDATE>
        <ENDDATE>07232017</ENDDATE>
      </SERVICEPROVIDER>
   </SERVICEINFO>
</SERVICECARD>

Open in new window

ItemAmountList-ItemAmount.JPG
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You have three slashes instead of two in
 Set colChildNodes = xdDoc.selectNodes("///ITEMAMOUNT")
should be
 Set colChildNodes = xdDoc.selectNodes("//ITEMAMOUNT")

Author

Commented:
To my rescue once again! I also forgot to add a .text to the end of my line. Thank you for all your help :}
You are welcome

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial