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)
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
|
|
|
|
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)
What if you change "TO/Test" to "//TO/test"??
|
|
|
|
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)
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
|
|
|
|
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)
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>
|
|
|
|
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)
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
|
|
|
|