problems getting nodes from XML

Author Message
kelphis

  • Total Posts : 10
  • Scores: 0
  • Reward points : 0
  • Joined: 4/19/2007
  • Status: offline
problems getting nodes from XML Thursday, April 19, 2007 8:24 AM (permalink)
0
im having the toughest time getting my selectSingleNode function to work.  It doesnt want to select anything.  I keep getting this error :
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[object]'
/VBSportal/welcome.asp, line 66
 
The red line is the one that is failing.  what am i doing wrong.
 
[/color][color=#000000]
     set divXML=server.createobject("Microsoft.XMLDOM")
     divXML.async=false
 
     divXML.loadXML(xmltxt)
     
     dim sel
     sel = "<select name='divlist' value='-- Choose division --'>"
     
     dim code
     dim desc
     [color=#ff0000]set divs = divXML.selectsinglenode("/DATA/DIVS").childNodes[/color]
 
     for each div in divs
         code = div.Text
         desc = code.Substring(3)
         code = code.Substring(1, 1)
         sel = sel & "<option value='" & code & "'>" & desc & "</option>"
     next
     sel = sel & "</select>"
     
     response.write(sel)
 

 
 
This is my xml :
the blue tag is what I want to select so that I can create a select box of all the DIV items.
<DSIOUT>
    <DATE>04-19-2007 15:14:31</DATE>
    <XMLVERSION>1.0</XMLVERSION>
    <XMLENCODING>UTF-8</XMLENCODING>
    <DATA>
        <DIVS>
            <DIV>P-PACCAR</DIV>
            <DIV>B-MERCEDES</DIV>
            <DIV>F-FREIGHTLINER</DIV>
            <DIV>M-MACK</DIV>
            <DIV>C-CUMMINS</DIV>
            <DIV>D-DETROIT</DIV>
        </DIVS>
    </DATA>
</DSIOUT>
 
#1
    kelphis

    • Total Posts : 10
    • Scores: 0
    • Reward points : 0
    • Joined: 4/19/2007
    • Status: offline
    RE: problems getting nodes from XML Friday, April 20, 2007 2:40 AM (permalink)
    0
    I think this is an encoding issue.  Im getting my XML from a web service.  i took the code from the web service and pasted it directly into the script and it works.  however when the exact same code is returned from the web service it doesnt work.  can this be an encoding issue?
     
    #2
      dm_4ever

      • Total Posts : 3687
      • Scores: 82
      • Reward points : 0
      • Joined: 6/29/2006
      • Location: Orange County, California
      • Status: offline
      RE: problems getting nodes from XML Saturday, April 21, 2007 8:11 AM (permalink)
      0
      What if you tried this:
      divXML.selectsinglenode("//DSIOUT/DATA/DIVS").childNodes
      dm_4ever

      My philosophy: K.I.S.S - Keep It Simple Stupid
      Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
      Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
       
      #3
        kelphis

        • Total Posts : 10
        • Scores: 0
        • Reward points : 0
        • Joined: 4/19/2007
        • Status: offline
        RE: problems getting nodes from XML Monday, April 23, 2007 1:17 AM (permalink)
        0
        I think I tried that.  I really think its an encoding issue.   I could be wrong but the reason that I think this is because if I copy the xml as a static string into the program it works fine.  but when the web service returns this I cant select anything.


        Error Type:
        Microsoft VBScript runtime (0x800A01A8)
        Object required: 'divXML.selectsinglenode(...)'
        /VBSportal/functions.asp, line 33

        note:

        i had the program response.write() out the output that I recieve from the web service without doing the LoadXML().  this is what is returned from the web service:
        <?xml version="1.0" encoding="utf-8"?>
        <string xmlns="&lt;DIVS&gt;&lt;DV&gt;P-PACCAR&lt;/DV&gt;&lt;DV&gt;B-MERCEDES&lt;/DV&gt;&lt;DV&gt;F-FREIGHTLINER&lt;/DV&gt;&lt;DV&gt;M-MACK&lt;/DV&gt;&lt;DV&gt;C-CUMMINS&lt;/DV&gt;&lt;DV&gt;D-DETROIT&lt;/DV&gt;&lt;DV&gt;K-CATERPILLAR&lt;/DV&gt;&lt;DV&gt;W-VOLVO/GM&lt;/DV&gt;&lt;DV&gt;X-MISCELLANEOUS&lt;/DV&gt;&lt;DV&gt;R-REBUILT&lt;/DV&gt;&lt;DV&gt;H-HARDWARE&lt;/DV&gt;&lt;DV&gt;O-GAS'>http://localhost/DSWebService/WebService">&lt;DIVS&gt;&lt;DV&gt;P-PACCAR&lt;/DV&gt;&lt;DV&gt;B-MERCEDES&lt;/DV&gt;&lt;DV&gt;F-FREIGHTLINER&lt;/DV&gt;&lt;DV&gt;M-MACK&lt;/DV&gt;&lt;DV&gt;C-CUMMINS&lt;/DV&gt;&lt;DV&gt;D-DETROIT&lt;/DV&gt;&lt;DV&gt;K-CATERPILLAR&lt;/DV&gt;&lt;DV&gt;W-VOLVO/GM&lt;/DV&gt;&lt;DV&gt;X-MISCELLANEOUS&lt;/DV&gt;&lt;DV&gt;R-REBUILT&lt;/DV&gt;&lt;DV&gt;H-HARDWARE&lt;/DV&gt;&lt;DV&gt;O-GAS, OIL AND GREASE&lt;/DV&gt;&lt;DV&gt;Y-YAMAHA&lt;/DV&gt;&lt;DV&gt;S-DIRECT SHIP PACCAR&lt;/DV&gt;&lt;DV&gt;N-NISSAN&lt;/DV&gt;&lt;DV&gt;I-INTERNATIONAL&lt;/DV&gt;&lt;DV&gt;V-VOLVO&lt;/DV&gt;&lt;DV&gt;Z-ZEBRA&lt;/DV&gt;&lt;DV&gt;U-ISUZU&lt;/DV&gt;&lt;DV&gt;a-stuff&lt;/DV&gt;&lt;/DIVS&gt;</string>
         
         
        Update:  I just realized that I should tell  you that I made a change to the xml.  notice that the DIV tags are now DV.  a co worker pointed out that DIV is already a used tag so I changed it.

        <message edited by kelphis on Monday, April 23, 2007 1:24 AM>
         
        #4
          kelphis

          • Total Posts : 10
          • Scores: 0
          • Reward points : 0
          • Joined: 4/19/2007
          • Status: offline
          RE: problems getting nodes from XML Monday, April 23, 2007 4:19 AM (permalink)
          0
          i found a work around and I dont like it but it works.  i have to do 2 loads of the XML and it works.
           
                  divXML.LoadXml(ws.QueryWebService())
                  divXML.LoadXml(divXML.text)
           
          does this help anyone kinda figure out what im doing wrong?
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9