Jump to content

Update XML fields with User input


IZZI
 Share

Recommended Posts

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")

 

Link to comment
Share on other sites

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
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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...