ASP keyword Query XML code _ Application Tips

Source: Internet
Author: User
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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.