现在有一个xml,格式如下:
<date>
<item>
<id> 1 </id>
<name> ABC </name>
</item>
<item>
<id> 2 </id>
<name> cde </name>
</item>
<item>
<id> 3 </id>
<name> efg </name>
</item>
</date>
我用ASP查询id=2,输入相应name的值,请问一下怎么写?用ASP的
dim id
id= "2 "
Set objXML = Server.CreateObject( "Microsoft.XMLDOM ")
objXML.Load(server.MapPath(filePath))
Set objNodes = objXML.selectSingleNode( "date/item[id = '' " & id & " ''] ")
//查询name话把上面的id变为name就可以了
查询ID,怎么输出相关的name?
dim id
id= "2 "
Set objXML = Server.CreateObject( "Microsoft.XMLDOM ")
objXML.Load(server.MapPath(filePath))
Response.Write(objXML.selectSingleNode( "date/item[id = '' " & id & " '']/name ").text)
如果ID有重复的,调用就是:
Set objNodes = objXML.selectNodes( "date/item[id = '' " & id & " ''] ")
进行循环输出。
11
22
33