I have an XML file containing details about individual users. When they visit a web page, I want to find their node and display the relevant information. I've been trying several example codes found here but there are some methods or properties I don't know how to access.
This is the XML:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<user id="001" name="Maria">
<godate>2015-01-01</godate>
<serials>
<serial>AA-12345-1</serial>
</serials>
</user>
<user id="002" name="Domingo">
<godate>2015-02-02</godate>
<serials>
<serial>BB-12345-1</serial>
<serial>BB-12345-2</serial>
</serials>
</user>
<user id="003" name="Michael">
<godate>2015-03-03</godate>
<serials>
<serial>CC-12345-1</serial>
<serial>CC-12345-2</serial>
<serial>CC-12345-3</serial>
</serials>
</user>
</data>
I need to find a node based on the ID attribute, and then display the value of the godate and the values (1 to n) of their serials. So, for Domingo the output should show:
Go Date: 2015-02-02
Serial 1: BB-12345-1
Serial 2: BB-12345-2
So far the closest I've been able to come is to display all the godate values and all the serial values, but I don't know how to limit the results to one user (based on ID) and only show the godate and serials for that one user.
This is the ASP code I have so far:
<%
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load(Server.MapPath("data.xml"))
Set Root = objXMLDoc.documentElement
Set NodeList = Root.getElementsByTagName("user")
For i = 0 to NodeList.length -1
Set GoDate = objXMLDoc.getElementsByTagName("godate")(i)
response.write "Go Date: " & godate.text & "<br>"
Set Serials = objXMLDoc.getElementsByTagName("serials")(i)
response.write "Serials: " & serials.text & "<br>"
Next
%>
How can I find the ID attribute and then only get the data for that node?