Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop thru XML format table

Status
Not open for further replies.

huobaji

Technical User
Sep 20, 2010
23
US
Thanks in Advance

I'm having a problem getting the values from this XML file.
I can loop throught the XML file however the values does not line up correct.

example: I want to get all the OrginaID and CIPCODE values
that are associated with the SessionDesignator. I tried looping thru the the XML it works but does not lineup the right SessionDesignator with OrginaID and CIPCODE


My Code

Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("/XML/" & fname))
Dim ID, cs, cip
Set objLst1 = xml.getElementsByTagName("OriginaID")
Set objLst2 = xml.getElementsByTagName("SessionDesignator")
Set objLst3 = xml.getElementsByTagName("CIPCode")

For i = 0 to (objLst1.length - 1)

ID = objLst1.item(i).text
cs = objLst2.item(i).text
cip = objLst3.item(i).text


Response.Write("<CENTER><Table width=640 border=1>" & _
"<tr><th bgcolor='#993300'><span class='style1'> OrginalD<br><FONT SIZE='-2'>"& _
"<TH BGCOLOR='#993300'><span class='style1'><FONT SIZE='-0'>" & "Session" & _
"<TH BGCOLOR='#993300'><span class='style1'><FONT SIZE='-0'>" & "CIPCode" & "</FONT>"&"</tr>")


Response.Write"<tr align=left><td>" & ID & " </td><td> " & cs & " </td> <td>" & _
cip & "</td></tr>"
Next

Set xml = Nothing


MY XML FILE
<Session>
<SessionDesignator>2010-01</SessionDesignator>
<crs>
<CIPCode>269999</CIPCode>
<OriginaID>174</OriginaID>
</crs>
<crs>
<CIPCode>240103</CIPCode>
<OriginaID>801</OriginaID>
</crs>
<crs>
<CIPCode>420101</CIPCode>
<OriginalID>100</OriginaID>
</crs>
<crs>
<CIPCode>240103</CIPCode>
<OriginalD>111</OriginaID>
</crs>
<crs>
<CIPCode>270101</CIPCode>
<OriginalD>151</OriginalD>
</crs>
<crs>
<CIPCode>400501</CIPCode>
<OriginalD>172</OriginalD>
</crs>
</Session>

<Session>
<SessionDesignator>2010-06</SessionDesignator>
<crs>
<CIPCode>400501</CIPCode>
<OriginalD>173</OriginalD>
</crs>
<crs>
<CourseCIPCode>400801</CourseCIPCode>
<OriginalD>117</OriginaID>
</crs>
</Session>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top