Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 19th, 2005, 03:58 AM
Authorized User
Join Date: Apr 2004
Location: , , .
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default access sub nodes using XMLDOM

Hi! I have an XML file which has this node:

  <D2 />
  <D3 />
  <D4 />
  <D5 />
  <D6 />
  <D7 />

I need to access the values of D0 and D1. I came up with this code:
        Dim xml
    Set xml = Server.CreateObject("Microsoft.XMLDOM")
    xml.async = False
    xml.load (Server.MapPath("sample.xml"))

        Dim test
    test = xml.getElementsByTagName("TEST").item(0).text
    Set xml = Nothing

I am able to get this: 000000000000000.00 000000000000000.00

But this is not what I need. I need to get the values separately (i.e. array or something). How do I do this?
Reply With Quote
  #2 (permalink)  
Old January 19th, 2005, 05:57 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

You can be more precise by using selectNodes or selectSingleNode methods, combined with XPath selection.

xml.selectSingleNode("/ROOT/TEST/D0").text gives value of the D0

xml.selectNodes("/ROOT/TEST/*") gives you a nodelist object containing all elements D0...D7 - u can use this like an array by accessing items by index number or using For Each varChildNode in theNodeList

Finally Microsoft.XMLDOM is very old version. Try one of these later versions instead:

Reply With Quote
  #3 (permalink)  
Old January 19th, 2005, 09:43 PM
Authorized User
Join Date: Apr 2004
Location: , , .
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts

What are the requirements of MSXML2.DOMDocument.4.0/MSXML2.DOMDocument.3.0? msxml3.dll/msxml3.dll right? are these built in components? or do you have to install it first?

thanks for your help phil! i already found a solution...thanks again!

set test = xml.getElementsByTagName("test")
Set xml = Nothing

dim objChild
For Each objChild In test

if objChild.hasChildNodes() then
    do while (i<objChild.childNodes.length and flag=0)
        if objChild.childNodes(i).text="" then
            response.write i&"-"
            response.write objChild.childNodes(i).text
        end if
end if

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pogramming the XmlDOM in C# sencee C# 5 March 10th, 2006 11:09 AM
XMLDOM problem braindog_43 Javascript How-To 2 January 16th, 2005 01:54 PM
XMLDOM problem braindog_43 XML 2 January 16th, 2005 01:38 PM
ASP3 / XMLDOM / updating nodes -- HELP PLEASE Michael Yevdokimov XML 1 January 3rd, 2005 12:37 PM
ASP3 / XMLDOM / updating nodes -- HELP PLEASE Michael Yevdokimov Classic ASP XML 0 December 30th, 2004 11:59 AM

All times are GMT -4. The time now is 01:35 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.