Classic ASP - Looping thru XML to display Elements and Attributes

CeftpastStask

New Member
Some elements have attributes (ID, NAme, Topic) while others do not.Trying to figure out how to display each element, and if it has attributes then display them too. I would like the end result to look like this.-- DESIRED LAYOUT --\[code\] GUIDE SPECS Product: 1721 Release: B132 Name: OUTDOOR SERIES DAT Comp: X02 DAT Min Ver: 890 PARAMETERS ID: 80000 NAME: PRODUCT NAME Topic: Reference Data Desc: 6-character ASCII Notes: Unique id used to identify product. Units: None MaxLength: 6 MinValue: 000001 MaxValue: 200000 Help: Rules: No Duplicates ID: 80010 NAME: STORE IDENTIFICATION Topic: Reference Data Desc: 4-character ASCII Notes: Unique id used to identify store. Units: None MaxLength: 4 MinValue: 0001 MaxValue: 9000 Help: Rules: No Duplicates\[/code\]-- EXAMPLE XML --\[code\]<ProgrammingGuide Label="J13200012" Version="003" XmlCompatibility="1"> <Product Label="B">1721</Product> <Release Label="B132">B132</Release> <Name>OUTDOOR SERIES</Name> <VCP-MinVersion>1</VCP-MinVersion> <DAT-Compatibility>X02</DAT-Compatibility> <DAT-MinVersion>890</DAT-MinVersion> <Configuration> <Parameter ID="80000" Name="PRODUCT NAME" Topic="Reference Data" TopicOrder="1"> <ParameterDescription>6-character ASCII</ParameterDescription> <ParameterNotes>Unique id used to identify product.</ParameterNotes> <ParameterAttributes Units="None" MaxLength="6" MinValue="http://stackoverflow.com/questions/12269870/000001" MaxValue="http://stackoverflow.com/questions/12269870/200000" /> <ParameterHelp>No Duplicates</ParameterHelp> <ParameterRuleText /> </Parameter> <Parameter ID="80010" Name="STORE IDENTIFICATION" Topic="Reference Data" TopicOrder="1"> <ParameterDescription>4-character ASCII</ParameterDescription> <ParameterNotes>Unique id used to identify store</ParameterNotes> <ParameterAttributes Units="None" MaxLength="4" MinValue="http://stackoverflow.com/questions/12269870/0001" MaxValue="http://stackoverflow.com/questions/12269870/9000" /> <ParameterHelp>No Duplicates</ParameterHelp> <ParameterRuleText /> </Parameter> </Configuration></ProgrammingGuide>\[/code\]-- CODE (for the Parameters) --\[code\]set ElemParameter = objxml.getElementsByTagName("Parameter")set ElemDesc = objxml.getElementsByTagName("ParameterDescription")set ElemNotes = objxml.getElementsByTagName("ParameterNotes")For i = 0 To (ElemParameter.length -1) If objxml.documentelement.childnodes.length > 0 Then For Each oNode In objxml.SelectNodes("/ProgrammingGuide/Configuration/Parameter") sID = oNode.GetAttribute("ID") sName = oNode.GetAttribute("Name") sTopic = oNode.GetAttribute("Topic") Response.Write "Parameter ID = "& sID &"<BR>" Response.Write "Parameter Name = "& sName &"<BR>" Response.Write "Parameter Topic = "& sTopic &"<BR><BR>" Next For Each oNode In objxml.SelectNodes("/ProgrammingGuide/Configuration/ParameterAttributes") sUnits = oNode.GetAttribute("Units") sMinVal = oNode.GetAttribute("MinValue") sMaxVal = oNode.GetAttribute("MaxValue") Response.Write "Units = "& sUnits &"<BR>" Response.Write "Min Value = "http://stackoverflow.com/questions/12269870/& sMinVal &"<BR>" Response.Write "Max Value = "http://stackoverflow.com/questions/12269870/& sMaxVal &"<BR>" Next End If Response.Write "Parameter Desc = " Response.Write(ElemDesc.item(i).Text) & "<br>" Response.Write "Parameter Notes = " Response.Write(ElemNotes.item(i).Text) & "<br><BR>" Next\[/code\]
 
Back
Top