Simple XML update?

Author Message
TNO

  • Total Posts : 2094
  • Scores: 36
  • Reward points : 0
  • Joined: 12/18/2004
  • Location: Earth
  • Status: offline
Simple XML update? Tuesday, June 05, 2007 1:03 PM (permalink)
0
I'm having what I hope is a simple problem:

Object Required: Line 14
 
save.asp
[/color]
 <%
 Dim objDom
 Dim objRoot
 Dim objField
 
 Set objDom = Server.CreateObject("Microsoft.XMLDOM")
  
 objDom.async=False
  
 objDom.load("TO.xml")
 
 Set objField = objDom.selectSingleNode("TO/test")
 
 objField.Text = Request.QueryString
 
 objDom.save "TO.xml"
 
 Set objDom = Nothing
 Set objRoot = Nothing
 Set objField = Nothing
 
 %>[color=#000000]
 


XML:
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <TO>
 
   ...
 
 <test></test>
 </TO>
 


Any idea what the issue is? No doubt something simple I'm overlooking
<message edited by TNO on Tuesday, June 05, 2007 2:12 PM>
To iterate is human, to recurse divine. -- L. Peter Deutsch
 
#1
    dm_4ever

    • Total Posts : 3687
    • Scores: 82
    • Reward points : 0
    • Joined: 6/29/2006
    • Location: Orange County, California
    • Status: offline
    RE: Simple XML update? Tuesday, June 05, 2007 4:51 PM (permalink)
    0
    What if you change "TO/Test" to "//TO/test"??
    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
     
    #2
      TNO

      • Total Posts : 2094
      • Scores: 36
      • Reward points : 0
      • Joined: 12/18/2004
      • Location: Earth
      • Status: offline
      RE: Simple XML update? Tuesday, June 05, 2007 6:24 PM (permalink)
      0
      hmm...still having the same issue, even when I rewrote it from scratch:
       
      Object required line 13
       
        <%
       Option Explicit
       Dim xmlDoc,rootEl,f
        
       'Load XML file
       set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
       xmlDoc.async = false
       xmlDoc.load("TO.xml")
        
       'Set the rootEl variable equal to the root element
       Set rootEl = xmlDoc.documentElement
        
       set f = rootEl.selectSingleNode("test") '<----Object required???
        
       f.Text = "Success!"
        
       'Save the modified XML file
       xmlDoc.save "TO.xml"
        
       'Release all object references
       set xmlDoc=nothing
       set rootEl=nothing
       set f=nothing
       %>
       

      To iterate is human, to recurse divine. -- L. Peter Deutsch
       
      #3
        ehvbs

        • Total Posts : 3321
        • Scores: 110
        • Reward points : 0
        • Joined: 6/22/2005
        • Location: Germany
        • Status: offline
        RE: Simple XML update? Wednesday, June 06, 2007 5:12 AM (permalink)
        0
        Hi TNO,

        given an accessible/valid xml file, this:

          Dim objDom : Set objDom = CreateObject( "Microsoft.XMLDOM" )
          objDom.async = False
          If objDom.load( "TO.xml" ) Then
             Dim objField : Set objField = objDom.selectSingleNode( "TO/test" )
             If objField Is Nothing Then
                WScript.Echo "nix"
             Else
                WScript.Echo objField.tagName, objField.firstChild.Text
             End If
          Else
             WScript.Echo objDom.parseError.reason
          End If
         
         --------- TO.xml -------------
         <?xml version="1.0" encoding="ISO-8859-1"?>
         <TO>
         <test>Versuch</test>
         </TO>
         
         --------- output -----------
         === xmlTNO: TNO's xml problem =======
         test Versuch
         === xmlTNO: 0 done (00:00:00) =======
         


        works for me. So I think there is something fishy with your file (server path mapping, permissions,
        or even the xml).

        Good luck!

        ehvbs

        P.S. I checked using "objField.Text" instead of "objField.firstChild.Text" - no problem either.
        <message edited by ehvbs on Wednesday, June 06, 2007 5:18 AM>
         
        #4
          TNO

          • Total Posts : 2094
          • Scores: 36
          • Reward points : 0
          • Joined: 12/18/2004
          • Location: Earth
          • Status: offline
          RE: Simple XML update? Wednesday, June 06, 2007 5:42 AM (permalink)
          0
          Thanks for the help. It was actually a combination of two things:
           
          Permissions
           
          xmlDoc.load("TO.xml") --> xmlDoc.load(Server.MapPath("TO.xml"))
          To iterate is human, to recurse divine. -- L. Peter Deutsch
           
          #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