Asp reads the child node value of the XML file

Source: Internet
Author: User

XML data is as follows:
==========================================
<? Xml version = "1.0" encoding = "UTF-8"?>
<Bluesky>

<MentList>
<Link ID = "1">
<Name> homepage </Name>
<URL>/</URL>
</Link>
<Link ID = "2">
<Name> Information Query </Name>
<URL>/</URL>
</Link>
<Link ID = "3">
<Name> document center </Name>
<URL>/</URL>
</Link>
<Link ID = "4">
<Name> webpage effect </Name>
<URL>/</URL>
</Link>
<Link id = "5">
<Name> website favorites </Name>
<URL>/</URL>
</Link>
<Link id = "6">
<Name> User discussion board </Name>
<URL>/</URL>
</Link>
</Mentlist>

<Pagesize>
<Article> 20 </Article>
<JScript> 20 </JScript>
<Guestbook> 15 </guestbook>
</Pagesize>

</Bluesky>

 

'// First define and create an XML Object
Dim oxml, oxmlroot, oxmlitems, oxmllinks, oxmlitem, ilength, I

Set oxml = Createobject ("Microsoft. xmldom") '// or msxml2.domdocument

'// Then load the XML document
OXML. load "XML file address" '// or: oXML. loadXML "XML content"

'// After the content is loaded, load its node information now
'// Retrieve all XML nodes

Set oXMLRoot = oXML.doc umentElement
'// Get the node
Set oXMLItems = oXMLRoot. selectNodes ("MentList ")

'// The oXMLItems variable contains the content of all MentList nodes.
'// If you want to obtain the Link node below it, use the following statement
'// Get the node. If there is only one MentList node, then 0 is its content.
SetoXMLLinks = oXMLItems (0). selectNodes ("Link ")
'// Obtain the node length (number of nodes)
ILength = oXMLLinks. length-1

For I = 0 To iLength
Set oXMLItem = oXMLLinks. item (I)
'// Use the getAttribute method to obtain its attribute value
Response. write oXMLItem. getAttribute ("ID ")
'// Use the selectSingleNode method to obtain its node Value
Response. write oXMLItem. selectSingleNode ("Name"). text
Response. write oXMLItem. selectSingleNode ("URL"). text
Next
'// Release the XML Object
Set oxmlitem = nothing
Set oxmllinks = nothing
Set oxmlitems = nothing
Set oxmlroot = nothing
Set oxml = nothing

This is the general idea. You can change it to meet your requirements.

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.