接受用户输入并用于保存XML输出文件 [英] Take user input and use to save XML output file

查看:76
本文介绍了接受用户输入并用于保存XML输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,可以为我们将大规模部署的Mifi盒创建xml配置文件.我希望能够从用户那里获取有关配置文件命名的信息.我在下面留下的唯一代码是添加了更多代码,这是我创建所有配置文件XML字段的800多行内容.

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"  



但它告诉我xmlDoc.Save不支持此方法.有人可以帮忙吗?



but it is telling me that the xmlDoc.Save does not support this method. Can anyone help?

推荐答案

尝试以下操作:http://social.msdn.microsoft.com/Forums/en-US/jscript/thread/fc6618f1-5130-47de-9840-c66af68d6c85 [ ^ ]
Try this : http://social.msdn.microsoft.com/Forums/en-US/jscript/thread/fc6618f1-5130-47de-9840-c66af68d6c85[^]


这篇关于接受用户输入并用于保存XML输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆