code_junkie

Asp XML Parsing

Nov 11th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. print("<?xml version="1.0" encoding="UTF-8"?>
  2. <user_data>
  3. <execution_status>0</execution_status>
  4. <row_count>1</row_count>
  5. <txn_id>stuetd678</txn_id>
  6. <person_info>
  7. <attribute name="firstname">john</attribute>
  8. <attribute name="lastname">doe</attribute>
  9. <attribute name="emailaddress">[email protected]</attribute>
  10. </person_info>
  11. </user_data>");
  12.  
  13. Dim oXML, oNode, sKey, sValue
  14.  
  15. Set oXML = Server.CreateObject("MSXML2.DomDocument.4.0")
  16. oXML.LoadXML(sXML)
  17.  
  18. For Each oNode In oXML.SelectNodes("/user_data/person_info/attribute")
  19. sKey = oNode.GetAttribute("name")
  20. sValue = oNode.Text
  21. ' Do something with these values here
  22. Next
  23.  
  24. Set oXML = Nothing
  25.  
  26. Dim oXML, oNode, sKey, sValue
  27.  
  28. Set oXML = Server.CreateObject("MSXML2.DomDocument.6.0") 'creating the parser object
  29. oXML.LoadXML(sXML) 'loading the XML from the string
  30.  
  31. For Each oNode In oXML.SelectNodes("/user_data/person_info/attribute")
  32. sKey = oNode.GetAttribute("name")
  33. sValue = oNode.Text
  34. Select Case sKey
  35. Case "execution_status"
  36. ... 'do something with the tag value
  37. Case else
  38. ... 'unknown tag
  39. End Select
  40. Next
  41.  
  42. Set oXML = Nothing
Add Comment
Please, Sign In to add comment