当前位置: 代码迷 >> XML/SOAP >> 用ASP访问XML节点属性值?/,该如何解决
  详细解决方案

用ASP访问XML节点属性值?/,该如何解决

热度:489   发布时间:2012-02-12 17:16:33.0
用ASP访问XML节点属性值????/
如<people>
  <name is="123">yangchao</name>
  .....
  </people>
我选取<people>为节点,现在想访问is="123",用ASP怎么实现?我知道如果访问<people>的节点属性是xml.getAttribute("is"),但是我现在想访问<name>的属性该怎么做?

------解决方案--------------------
这个跟ASP没什么关系吧~都是用js调用XML节点数据吧~
你看看这个:
http://www.w3school.com.cn/xmldom/dom_nodes_get.asp
------解决方案--------------------
可以参考这里:http://blog.csdn.net/cds27/archive/2007/04/24/1579866.aspx
------解决方案--------------------
VBScript code

<%

Set oDoc    = CreateObject("Msxml2.DOMDocument")
With oDoc
    .async              = False
    .validateOnParse    = False
    .preserveWhiteSpace = False
    .resolveExternals   = False
    .setProperty "SelectionLanguage", "XPath"
    .loadXML "<people><name is=""123"">yangchao</name></people>"
    If .parseError.errorCode <> 0 Then
        sErrMsg     = .parseError.errorCode & "|" &_
                      .parseError.srcText & "|" & .parseError.reason
        Response.Write sErrMsg
        Response.End
    End If

    Set oNode   = oDoc.selectSingleNode("//name[@is='123']")
    If Not oNode Is Nothing Then
        Response.Write oNode.text
    End If
    Set oNode = Nothing
End With
Set oDoc = Nothing
%> 
  相关解决方案