Requires the incoming employee number to return the employee's name
'Global data is considered to be loaded only once
set Doc = CreateObject("Microsoft.XMLDOM")
Doc.async = false
Doc.load(Server.MapPath("user_cnname.xml"))
function cnname_var (varusername)
dim node,i,nodecount,root
set nodeLis= Doc.getElementsByTagName("user")
nodeCount = nodeLis.length
For i=0 to nodeCount - 1
if nodeLis.item(i).childnodes.item(0).text = varusername then
'There is a little doubt here why it is item(2)
cnname_var = nodeLis.item(i).childnodes.item(2).text
exit function
end if
next
cnname_var = varusername
The end function
xml file is as follows:
<?xml version="1.0" encoding="gb2312"?>
<user_cnname>
<user>
<username>A140</username>
<cnname>Zhao Jianchuan</cnname>
</user>
<user>
<username>A141</username>
<cnname>Zhao Jianchuan</cnname>
</user>
</user_cnname>
But this method is not as fast as querying directly from the database, so this method is not used.
Query can also be implemented using javascript + data island, but it is not easy to call in asp code if there are no small things involved.