xml - 使用经典 ASP 获取节点属性的值

标签 xml asp-classic

我有以下 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/

相关文章:

java - 如何使用 XMLDog 从 xml 文件中检索值

javascript - 在 AngularJS 中将 XML 解析为 HTML 表

iis-7 - 经典asp : Error '800a01ad' ActiveX component can't create object

HTML 和 ASP 文件中的 Javascript

javascript - 如何更改由 JavaScript 函数生成的 docx 中的字体

sql - 为 10k+ 用户保存用户数据的最佳方法

xml - Scala:合并 xml 数据树?

function - 从经典 ASP 中的函数返回记录集

javascript - 通过 if 语句将经典 ASP 值返回到 javascript

html - 使用 css 样式化按钮