Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


How to replace xml value URGENT!!!

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,42459
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to replace xml value URGENT!!!
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 How to replace xml value URGENT!!! - 1/24/2007 12:51:31 PM   
  buffalokml

 

Posts: 15
Score: 0
Joined: 4/3/2006
Status: offline
Hi all,

What I want is to replace value for Macro name="ApplicationVersion" value="6.11.0" to   Macro name="ApplicationVersion" value="7.0.0" in the xml file for an example, but I got an error message " C:\Projects\Test.vbs(70, 4) Microsoft VBScript runtime error: Object doesn't support this property or method"

In addition, I could not query value. I'm stuck here. Please help!!!!!!!!

Here is my xml file
<?xml version="1.0" encoding="utf-8" ?>
<MY.Servers>

<!-- ******************************* -->
<!-- *** DLV Workflow Comments *** -->
<!-- ******************************* -->
<Server pattern="(TEST1.*)|(TEST2.)|(TEST3.*)">
     <Macro name="CommentTagOpen" value="" />
     <Macro name="CommentTagClose" value="" />
</Server>
<Server pattern="(TEST4.*)|(TEST5.*)">
 <Macro name="ApplicationEnvironment" value="Quality Assurance 01" />
 <Macro name="ApplicationVersion" value="6.11.0" />
 <Macro name="EnableOrderDataFabrication" value="true" />
 <Macro name="CurativeFaxNumber" value="(888) 888-8888" />
</Server>

</MY.Servers>

Here is my code.


Dim
oXDoc : Set oXDoc = CreateObject( "Msxml2.DOMDocument.4.0" )
 

xmlDoc.async=
"false"

oXDoc.load(
"C:\Projects\MyXML.xml")

If
(oXDoc.parseError.errorCode <> 0) Then

Dim myErr
Set myErr = oXDoc.parseError
MsgBox(
"You have error " & myErr.reason)

Else


oXDoc.setProperty
"SelectionLanguage", "XPath"

Set currNode = oXDoc.selectSingleNode("//book/author")
 

for each x in oXDoc.documentElement
i   WScript.Echo currNode.Text
next
End
If
 
 
 
 
 
Post #: 1
 
 RE: How to replace xml value URGENT!!! - 1/24/2007 1:47:21 PM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Your issue may be with this line:
Set currNode = oXDoc.selectSingleNode("//book/author")

maybe:
Set currNodes = oXDoc.selectNodes("//MY.Servers/Server/Macro")

or since an .xml is really just plain text, open it with the FileSystemObject, read it, use the Replace Function to replace your values, and then save it back to the xml file.


< Message edited by dm_4ever -- 1/24/2007 1:51:13 PM >


_____________________________

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

(in reply to buffalokml)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to replace xml value URGENT!!! Page: [1]
Jump to:





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
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts