Jump to content
IZZI

Update XML fields with User input

Recommended Posts

IZZI

I'm trying to write an autoit script to replace some line in an XML file with input I get from the user. I have only used autoit to do some basic software install automation. I've been searching and found some code in the forums that is able to do some of what I'm looking for. My problem is that it's only putting in the numerical values and won't put in any of the text values I give it or a that was supplied from the user. Here is a copy of the code I have now. If you can point me to what I'm doing wrong that would be great. Thanks

 

#Include <FileConstants.au3>
#include <file.au3>

;Prompt user for variable information
$ext = InputBox("Extension Numer", "Enter your phone extension number")
$extpass = InputBox("Voice Mail Password", "Enter your voicemail password", "", "*")
$alias = InputBox("Alias", "Enter your full name")

$replace1 = "@Phoneserver.domain.com/main"

Local $oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load("base.xml")
$oName = $oXML.SelectSingleNode("//name")
$oName.text = ($oName.text) + $ext + $replace1
$oExtpass = $oXML.SelectSingleNode("//password")
$oExtpass.text = ($oExtpass.text) + $extpass
$oAlias = $oXML.SelectSingleNode("//alias")
$oAlias.text = ($oAlias.text) + $alias
$oXML.save ("accounts.xml")

 

Share this post


Link to post
Share on other sites
jdelaney
Local $oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load("base.xml")
$oName = $oXML.SelectSingleNode("//name")
$oName.text = ($oName.text) & $ext & $replace1
$oExtpass = $oXML.SelectSingleNode("//password")
$oExtpass.text = ($oExtpass.text) & $extpass
$oAlias = $oXML.SelectSingleNode("//alias")
$oAlias.text = ($oAlias.text) & $alias
$oXML.save ("accounts.xml")

The + is actually adding the values.  Strings are converted to numbers, and then added together...use & instead, to join strings.

Edited by jdelaney
  • Like 1

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
IZZI

Dude you are awesome... Thanks for the info. That is something I didn't know. That change made all the difference and now the script works perfectly. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×