使用ASP / VB获取一个节点的属性值 [英] Using ASP/VB to get value of a node attribute

查看:121
本文介绍了使用ASP / VB获取一个节点的属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下XML架构:

 <lyrics>
      <response code="0">SUCCESS</response>
      <searchResults>
           <result id="120745" hid="gXTQx5ywE0M=" exactMatch="true">
                <title>Opera Singer</title>
                <artist>
                     <name>Cake</name>
                </artist>
           </result>
      </searchResults>
 </lyrics>

用VB,我怎么会得到精确匹配的价值?我已经尝试了很多不同的方法,但似乎没有任何工作。任何想法?

Using VB, how would I get the value of exactMatch? I have tried many different methods, but nothing seems to work. Any ideas?

推荐答案

试试这个:

Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
    xmldoc.async = true
    xmldoc.Load Server.MapPath("yourfile.xml")

'' // query for a specific result        
Set result = xmldoc.SelectSingleNode("//result[@id='120745']")
Response.Write(result.GetAttribute("exactMatch") & "<br />")

'' // get all results elements
Set results = xmldoc.SelectNodes("//result")
For Each result In results
    Response.Write(result.GetAttribute("exactMatch") & "<br />")
Next

这篇关于使用ASP / VB获取一个节点的属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆