Click here to Skip to main content
12,297,542 members (53,335 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VBScript XML
I have a script to create xml config files for Mifi boxes that we will be deploying on a large scale. I want to be able to take input from the user as to what the config file is named. I have added more code below the only thing I am leaving out are the 800+ lines of me creating all the config file XML fields.

Set xmlDoc = _
  CreateObject("Microsoft.XMLDOM")  
 
'here is where I create all the fields of the xml config file
'
'
'
'
'
'
'
'
'Code continued below.

strConfigFileName = UserInput ( "Enter output file name" )
 
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set OutputFileName = myFSO.OpenTextFile( "C:\Users\testing\Documents\Scripts\Edit XML\" & strConfigFileName & ".xml", 8, True)
OutputFileName.Close
 

xmlDoc.save ("C:\Users\testing\Documents\Scripts\Edit XML\" & OutputFileName)
 

 
xmlDoc.Async = "False"
xmlDoc.Load("C:\Users\testing\Documents\Scripts\Edit XML\" & OutputFileName)
 

 

strSsid = UserInput( "Enter Device SSID:" )
Set colNodes1=xmlDoc.selectNodes _
  ("/Hudson1/Profiles/Secure/ssid")
 
For Each objVersion in colNodes1
   objVersion.Text = strSsid
Next
 
strDeviceIp = UserInput( "Enter Device IP Address:" )
Set colNodes2=xmlDoc.selectNodes _
  ("/Hudson1/General/System/ipaddr")
 
For Each objVersion in colNodes2
   objVersion.Text = strDeviceIp
Next
 
strWpaPassword = UserInput( "Enter WPA Password:" )
'WScript.Echo "You entered: " & strInput

Set colNodes3=xmlDoc.selectNodes _
  ("/Hudson1/Profiles/Secure/psk")
 
For Each objVersion in colNodes3
   objVersion.Text = strWpaPassword
Next
 

strAdminPassword = UserInput( "Enter Admin Password:" )
'WScript.Echo "You entered: " & strInput

 
Set colNodes4=xmlDoc.selectNodes _
  ("/Hudson1/Router/HTTP/password")
 
For Each objVersion in colNodes4
   objVersion.Text = strAdminPassword
Next
    	
 

 

 
xmlDoc.save "C:\Users\testing\Documents\Scripts\VBScript to XML\mifisettings.xml"  

but it is telling me that the xmlDoc.Save does not support this method. Can anyone help?
Posted 5-Sep-12 9:28am
Edited 6-Sep-12 3:27am
v2
Comments
Wes Aday 5-Sep-12 15:33pm
   
And what type is xmlDoc?
ryanb31 5-Sep-12 16:24pm
   
Where is the code where you define xmlDoc?
Flatlineskillz 6-Sep-12 8:50am
   
Set xmlDoc = _
CreateObject("Microsoft.XMLDOM")
ryanb31 6-Sep-12 9:10am
   
According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms757828(v=vs.85).aspx the method is save, lowercase.
Flatlineskillz 6-Sep-12 9:12am
   
Tried that and it didnt work
ryanb31 6-Sep-12 9:15am
   
What happened when you used lowercase save?
Flatlineskillz 6-Sep-12 9:17am
   
same error object doesn't support this property or method
ryanb31 6-Sep-12 9:22am
   
Well, the documentation says it does. Doesn't mean the documentation is right. I think you need to show more of your code then.
Flatlineskillz 6-Sep-12 9:28am
   
I updated the code above. I added everything I have except for the many lines that create all the records and fields in the XML file. Regardless I appriciate you taking the time to help me out.
ryanb31 6-Sep-12 9:54am
   
If you look at the link I included the examples are actually creating a Msxml2.DOMDocument.3.0. You may want to try that instead. I wonder if what you are using is much older.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Flatlineskillz 7-Sep-12 11:14am
   
I am not sure what you mean. I tried switching to a newer version of the MSXMLDOM but I still get the same error. Do you mean try using an ActiveXObject. I apologize but I don't do much scripting and this is the first time I have used VBScript and XML together. Thanks for your time.
Mehdi Gholam 7-Sep-12 11:23am
   
If you don't have to use vbscript, use c# or vb.net instead it will much simpler and easier.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100