28,391
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="utf-8" ?>
<root>
<item>
<i name="english" value="英文" />
<i name="chinese" value="中文" />
</item>
</root>
<%
Response.Write search("english")
Response.Write search("chinese")
Function search(sValue)
s = "<?xml version=""1.0"" encoding=""utf-8"" ?>" &_
"<root>" &_
"<item>" &_
" <i name=""english"" value=""英文"" />" &_
" <i name=""chinese"" value=""中文"" />" &_
"</item>" &_
"</root>"
Set oDoc = CreateObject("Msxml2.DOMDocument")
With oDoc
.async = False
.validateOnParse = False
.preserveWhiteSpace = False
.resolveExternals = False
.loadXML s
If .parseError.errorCode <> 0 Then
sErrMsg = .parseError.errorCode & "|" &_
.parseError.srcText & "|" & .parseError.reason
Set oDoc = Nothing
search = sErrMsg
Exir
End If
Set oNode = .selectSingleNode("/root/item/i[@name='" & Replace(sValue, "'", "'") & "']")
If oNode Is Nothing Then
search = ""
Else
search = oNode.getAttribute("value")
End If
End With
Set oDoc = Nothing
End Function
%>