troubleshooting Question

Parsing XML with classic ASP

Avatar of Kristen Jones
Kristen JonesFlag for United States of America asked on
VB ScriptXMLASP
5 Comments1 Solution310 ViewsLast Modified:
I need to be able to separate child nodes and apply logic

my XML Source: https://vpic.nhtsa.dot.gov/api/vehicles/decodevin/ZPBUA1ZLXKLA00941?format=xml

For some reason the text values are concatenating but I want them to be broken out by the Node name and value.  I put notes in the code.  The Code DOES work just not how I need it.

  
<%

url = "https://vpic.nhtsa.dot.gov/api/vehicles/decodevin/ZPBUA1ZLXKLA00941?format=xml"
     
     ' add a BASE HREF tag
     Dim xmldoc
     dim xmlhttp 
      
     Response.write "<BASE HREF='" & url & "'><P>" & url  & "<P>"
    
     
     set xmlhttp = CreateObject("Microsoft.XMLHTTP")
     Set xmlDoc = CreateObject("Microsoft.XMLDOM") 
     xmlhttp.open "GET", url, false 
     xmlhttp.send ""
          'response.write xmlhttp.responsetext
          
          xmlDoc.async = False
          bresult=xmlDoc.loadxml(xmlhttp.responsetext)
       
       State = ""
        ' WORKS ...Set NodeList = xmlDoc.getElementsByTagName("*")
        'Set NodeList = xmlDoc.documentElement.selectNodes("/Response/*")
        'Set NodeList = xmlDoc.documentElement.selectNodes("/Response/Results/*")
   Set NodeList = xmlDoc.documentElement.selectNodes("/Response/Results/DecodedVariable")
        'Set NodeList = xmlDoc.documentElement.selectNodes("/Response/Results/DecodedVariable/*")






        For Each Node in NodeList




         'I NEED SOME SORT OF LOGIC HERE
	           If Node.tagName = "VariableId" Then		        
		        ' response.write Node.tagName & "<br>"	
		        ' Do Something LOGIC	       
	           End If  

           'I NEED SOME SORT OF LOGIC HERE
               'If Node.tagName("VariableId") = 156 then

               'End if






	        response.write "TagName: " &  Node.tagName & "<br>"	  
                response.write("Node.text :" & Node.text & "<br>") 
                response.write("Node.baseName :" & Node.baseName & "<br>") 
                response.write("Node.nodeName:" & Node.nodeName & "<br>") 
                response.write("Node.nodeType:" & Node.nodeType & "<br>") 
                response.write("Node.nodeValue:" & Node.nodeValue & "<br>")
        

	      
        Next
       
      
       set xmlhttp = nothing
%>
 

Current Output snippet
TagName: DecodedVariable
Node.text :142Suggested VIN
Node.baseName :DecodedVariable
Node.nodeName:DecodedVariable
Node.nodeType:1
Node.nodeValue:




TagName: DecodedVariable
Node.text :143Error Code00 - VIN decoded clean. Check Digit (9th position) is correct
Node.baseName :DecodedVariable
Node.nodeName:DecodedVariable
Node.nodeType:1
Node.nodeValue:




TagName: DecodedVariable
Node.text :144Possible Values
Node.baseName :DecodedVariable
Node.nodeName:DecodedVariable
Node.nodeType:1
Node.nodeValue:




TagName: DecodedVariable
Node.text :156Additional Error Text
Node.baseName :DecodedVariable
Node.nodeName:DecodedVariable
Node.nodeType:1
Node.nodeValue:




TagName: DecodedVariable
Node.text :10Destination Market17U.S.
Node.baseName :DecodedVariable
Node.nodeName:DecodedVariable
Node.nodeType:1
Node.nodeValue:




TagName: DecodedVariable
Node.text :26Make502LAMBORGHINI
Node.baseName :DecodedVariable
Node.nodeName:DecodedVariable
Node.nodeType:1
Node.nodeValue:
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 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 5 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