我有以下 XML 架构:
<?xml version="1.0" encoding="utf-8"?>
<PageMapping>
<Applications>
<Application name="xxx">
<Page name='Default.aspx' IsCaptured = "true" >
<Control name="btnSearch" IsCaptured = "true"/>
<Control name="btnSave" IsCaptured = "true"/>
<Control name="btnClick" IsCaptured = "true"/>
</Page>
<Page name='Login.aspx' IsCaptured = "true">
<Control name="btnSearch" IsCaptured = "true"/>
</Page>
<Page name='Home.aspx' IsCaptured = "true" >
<Control name="btnSearch" IsCaptured = "true"/>
</Page>
<Page name='User.aspx' IsCaptured = "true" />
</Application>
</Applications>
</PageMapping>
使用 ASP,如何获取“name”和“IsCaptured”的值?我尝试了各种不同的方法,但似乎没有任何效果。有什么想法吗?
最佳答案
试试这个:
Set oXML = Server.CreateObject("MSXML2.DomDocument.4.0")
oXML.LoadXML(sXML) ' sXML is a variable containing the content of your XML file
For Each oNode In oXML.SelectNodes("/PageMapping/Applications/Application/Page")
sName = oNode.GetAttribute("Name")
sIsCaptured = oNode.GetAttribute("IsCaptured")
' Do something with these values here
Next
Set oXML = Nothing
关于xml - 使用经典 ASP 获取节点属性的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8572132/