<%
Class DealXml
	
	'下拉列表
	'参数说明：
	'XmlFile--XML文件的物理路径；
	'selectId--下拉列表对象的ID；
	'selectName--下拉列表对象的名称；
	'initLable--初始化选中；
	'isSearch--是否为搜索做准备
	
	Function ListXml(XmlFile,selectId,selectName,initLable,isSearch)
		Dim doc
		Set doc = Server.CreateObject("Microsoft.XMLDOM")
		doc.Async=False
		doc.load(XmlFile)
		'LoadXmlFile(XmlFile)
		Dim root,subNodes,subList,nCntChd
		Set root = doc.documentElement		
		nCntChd=root.ChildNodes.length-1 
		Response.Write("<select id='"&selectId&"' name='"&selectName&"'>"&vbcrlf)
		If isSearch Then 
			Response.Write "<option value=''>全部范围</option>"&vbcrlf	
		End If
		if initLable<>"" Then initLable=Cstr(initLable)
		For i=0 to nCntChd
			If initLable=root.ChildNodes.item(i).getAttribute("lable") Then
				Response.Write "<option value='"&root.ChildNodes.item(i).getAttribute("lable")&"' selected='selected'>"&root.ChildNodes.item(i).ChildNodes.item(0).text&"</option>"&vbcrlf		
			Else
				Response.Write "<option value='"&root.ChildNodes.item(i).getAttribute("lable")&"'>"&root.ChildNodes.item(i).ChildNodes.item(0).text&"</option>"&vbcrlf	
			End If
		Next
		Response.Write("</select>"&vbcrlf)
	End Function
	
	
	'如果不存在,则返回false,存在则返回值
	Function GetTxt(XmlFile,initLable)
	If Not IsNull(initLable) Then initLable=Cstr(initLable)
		Dim doc
		Set doc = Server.CreateObject("Microsoft.XMLDOM")
		doc.Async=False
		doc.load(XmlFile)
		Dim root,subNodes,subList,nCntChd
		Set root=doc.selectSingleNode("/XmlList/SubXml[@lable='"&initLable&"']")
		
		'GetTxt= root.text
		If root is Nothing Then 
			GetTxt=False
		Else
			GetTxt= root.text
		End If		
		Set root=Nothing
		Set doc=Nothing		
	End Function
	
	Function ListProvince(XmlFile,selectId,selectName,initLable,isSearch)
		Dim doc
		Set doc = Server.CreateObject("Microsoft.XMLDOM")
		doc.Async=False
		doc.load(XmlFile)
		'LoadXmlFile(XmlFile)
		Dim root,subNodes,subList,nCntChd
		Set root=doc.selectSingleNode("/dlove/province_city")
		nCntChd=root.ChildNodes.length-1 
		Response.Write("<select id='"&selectId&"' name='"&selectName&"'>"&vbcrlf)
		If isSearch Then 
			Response.Write "<option value=''>全部范围</option>"&vbcrlf	
		End If
		if initLable<>"" Then initLable=Cstr(initLable)
		For i=0 to nCntChd
			If initLable=root.ChildNodes.item(i).getAttribute("key") Then
				Response.Write "<option value='"&root.ChildNodes.item(i).getAttribute("key")&"' selected='selected'>"&root.ChildNodes.item(i).getAttribute("value")&"</option>"&vbcrlf		
			Else
				Response.Write "<option value='"&root.ChildNodes.item(i).getAttribute("key")&"'>"&root.ChildNodes.item(i).getAttribute("value")&"</option>"&vbcrlf	
			End If
		Next
		Response.Write("</select>"&vbcrlf)
	End Function
	
	Function GetProvince(initLable)
		Dim doc
		Set doc = Server.CreateObject("Microsoft.XMLDOM")
		doc.Async=False
		doc.load(server.MapPath("/xml/const.xml"))
		'LoadXmlFile(XmlFile)
		Dim root,subNodes,subList,nCntChd
		Set root=doc.selectSingleNode("/dlove/province_city/province[@key='"&initLable&"']")
		If Not root is nothing Then
			GetProvince=root.getAttribute("value")			
		Else
			GetProvince=""
		End If
	End Function
	
	Function GetCity(p,c)
		Dim doc
		Set doc = Server.CreateObject("Microsoft.XMLDOM")
		doc.Async=False
		doc.load(server.MapPath("/xml/const.xml"))
		'LoadXmlFile(XmlFile)
		Dim root,subNodes,subList,nCntChd
		Set root=doc.selectSingleNode("/dlove/province_city/province[@key='"&p&"']/item[@key='"&c&"']")
		If Not root is nothing Then
			GetCity=root.getAttribute("value")			
		Else
			GetCity=""
		End If
	End Function
	
End Class
Dim xmlObj
Set xmlObj= New  DealXml
%>