Quantcast
Channel: Classic ASP
Viewing all articles
Browse latest Browse all 488

Parse XML in classic ASP

$
0
0

I'm trying to parse XML in classic ASP. The following code displays the XML file sequentially. How do I randomly access the fields <Product> and <SKU>? I've been trying to use getElementsByTagName method although I'm unable to get this working properly.

<%
Dim mydoc
Set mydoc=Server.CreateObject("Microsoft.XMLDOM")

mydoc.load(Server.MapPath("xml.xml"))
set nodes = mydoc.selectNodes("//*")

for i = 0 to nodes.length - 1
    response.write(nodes(i).nodeName & " - " & nodes(i).text & "<br />")
next
%>


xml file
--------
<?xml version="1.0" standalone="yes"?><NewDataSet><Table><Product>Test1</Product><SKU>AAA</SKU></Table><Table><Product>Test2</Product><SKU>BBB</SKU></Table></NewDataSet>


Viewing all articles
Browse latest Browse all 488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>