Now there is an XML that has the following format:
Copy Code code as follows:
<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>
I use ASP query id=2, enter the value of the corresponding name, how can I write? Using ASP's
Copy Code code as follows:
Dim id
Id= "2"
Set objxml = Server.CreateObject ("Microsoft.XMLDOM")
Objxml.load (server. MapPath (FilePath))
Set objnodes = Objxml.selectsinglenode ("Date/item[id = '" & ID & "]")
Query name to change the ID above to name.
Query ID, how do I output the related name?
Copy Code code as follows:
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)
If the ID is duplicated, the call is:
Copy Code code as follows:
Set objnodes = Objxml.selectnodes ("Date/item[id = '" & ID & "]")
For loop output.