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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Files & ASP Dropdown

Status
Not open for further replies.

Lbob

Programmer
May 23, 2003
157
GB
Hi

I've got an XML file that I use to populate a treeview control and a dropdown box. That works fine, although I now want to be able to sort the list of people in the dropdown list. Someone suggested using an XML template, but I'm a bit of an XML newbie and not sure how to do this. Can someone help.

This is what I've got to get the usernames out of the xml file and update fill the dropdown

Sub BuildXMLUsers()
'This loops thru the XML file and recursively calls ListXMLUSers to update the combo
'Restricts the combo to ONLY show the users listed in the XML file

dim oXMLNode
Dim sUniqueFileName
Dim iAdminUser, x, y, sDocument

'Gets the Querystring => retrieve the correct XML file
sDocument = document.location

x = instr(1,sDocument,"iAdmin=")
y = len(sDocument)

iAdminUser = right(sDocument, y - (x + 6))
sUniqueFileName = "XML/admin_users_" & iAdminUser & ".xml"

with oXML.XMLDocument
.async = false
if .load(sUniqueFileName) then
call ListXMLUsers(oXML.SelectSingleNode("/xml/user"))
else
msgbox "Couldn't load xml file because " & .parseError.reason
end if
end with

end sub

Sub ListXMLUsers(oXMLNode)
Dim oOption ' as object

set oOption = document.createElement("option")
call frmUser.cmbManager.options.add(oOption)

oOption.innerText = oXMLNode.selectSingleNode("@name").nodeValue
oOption.value = oXMLNode.selectSingleNode("@id").nodeValue

for each oXMLSubNode in oXMLNode.selectNodes("user")
Call ListXMLUsers(oXMLSubNode)
next

End Sub

Thanks
Lbob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top