Public Overloads Function GetValue(ByVal Slan As String, ByVal LanClass As String) As String
If Session("Lan") Is Nothing Or Session("Lan") = "" Then
Session("Lan") = "English"
End If
If Slan = "" Then
Return ""
Else
Dim XmlDoc As XmlDocument = New XmlDocument
Dim XPath As String = ""
XPath = XmlPath & Session("Lan") & ".Xml"
If System.IO.File.Exists(XPath) Then '判斷路徑是否存在
Try
XmlDoc.Load(XPath)
Catch ex As Exception
Return ex.ToString
End Try
Dim root As XmlNode = XmlDoc.DocumentElement
Dim xn As XmlNode
For Each xn In root.ChildNodes '遍歷所有的Lan子節點
Dim xe As XmlElement = CType(xn, XmlElement) '將子節點類型轉換XmlElement類型
Dim nls As XmlNodeList = xe.ChildNodes '繼續獲取xe子節點的所有子節點
If nls.Item(0).ChildNodes.Item(0).Value <> Nothing Then
If nls.Item(0).ChildNodes.Item(0).Value = CType(Slan, Integer) And nls.Item(2).ChildNodes.Item(0).Value = CType(LanClass, Integer) Then '第一個子節點(從0開始計數)
Dim xn1 As XmlNode
For Each xn1 In nls '遍歷Lan子節點的所有子節點,即一個子節點的所有元素
Dim xe2 As XmlElement = CType(xn1, XmlElement)
If xe2.Name = "Dlan" Then '如果該子節點名為Dlan
Return xe2.InnerText '返回值
Exit Function
End If
Next
End If
End If
Next
End If
Return ""
End If
End Function
If Session("Lan") Is Nothing Or Session("Lan") = "" Then
Session("Lan") = "English"
End If
If Slan = "" Then
Return ""
Else
Dim XmlDoc As XmlDocument = New XmlDocument
Dim XPath As String = ""
XPath = XmlPath & Session("Lan") & ".Xml"
If System.IO.File.Exists(XPath) Then '判斷路徑是否存在
Try
XmlDoc.Load(XPath)
Catch ex As Exception
Return ex.ToString
End Try
Dim root As XmlNode = XmlDoc.DocumentElement
Dim xn As XmlNode
For Each xn In root.ChildNodes '遍歷所有的Lan子節點
Dim xe As XmlElement = CType(xn, XmlElement) '將子節點類型轉換XmlElement類型
Dim nls As XmlNodeList = xe.ChildNodes '繼續獲取xe子節點的所有子節點
If nls.Item(0).ChildNodes.Item(0).Value <> Nothing Then
If nls.Item(0).ChildNodes.Item(0).Value = CType(Slan, Integer) And nls.Item(2).ChildNodes.Item(0).Value = CType(LanClass, Integer) Then '第一個子節點(從0開始計數)
Dim xn1 As XmlNode
For Each xn1 In nls '遍歷Lan子節點的所有子節點,即一個子節點的所有元素
Dim xe2 As XmlElement = CType(xn1, XmlElement)
If xe2.Name = "Dlan" Then '如果該子節點名為Dlan
Return xe2.InnerText '返回值
Exit Function
End If
Next
End If
End If
Next
End If
Return ""
End If
End Function