HariKara Posted April 16, 2018 Posted April 16, 2018 Hi All, Any AutoIT coders out there able to assist me? I have managed to work out how to update a "TAG", however, I now need to update a Key within the tag. XML code below: XML CODE: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup"> <section name="CP.Infrastructure.Properties.Settings" type="System.Configuration.ClientSettingsSection" /> </sectionGroup> </configSections> <userSettings> <CP.Infrastructure.Properties.Settings> <setting name="Dictionary" serializeAs="Xml"> <value> <dictionary> <items> <item key="LoginType">Username</item> <item key="LoginUsername">admin</item> <item key="LastConnectedServers">127.0.0.1</item> <item key="Fingerprint Server: 127.0.0.1">TEXT SPACE EDIT BEND IDEN WREN</item> <item key="GettingStarted">False</item> </items> </dictionary></value> </setting> </CP.Infrastructure.Properties.Settings> </userSettings> </configuration> I want to set the XML key highlighted in RED above from <item key="LoginUsername">admin</item> To <item key="LoginUsername"></item> I've tried many scripts but I either get a complete wipeout or nothing changes. Ive attached my base script that I'm trying. File2.au3
Earthshine Posted April 16, 2018 Posted April 16, 2018 what version of the udf are you using, it's up to 1.1.1.13 now My resources are limited. You must ask the right questions
HariKara Posted April 16, 2018 Author Posted April 16, 2018 @Earthshine Im not sure how to check? I've not called any specific UDF in my script and I'm a Newbie at this... How could I check quickly? Thanks Hari
Earthshine Posted April 16, 2018 Posted April 16, 2018 (edited) where did you get this #include "_XMLDomWrapper.au3" There is an XML UDF you can use Edited April 16, 2018 by Earthshine My resources are limited. You must ask the right questions
HariKara Posted April 16, 2018 Author Posted April 16, 2018 @Earthshine Copied and Pasted off the internet... See attached the named file. _XMLDomWrapper.au3
Earthshine Posted April 16, 2018 Posted April 16, 2018 I would use the ones from this site My resources are limited. You must ask the right questions
HariKara Posted April 16, 2018 Author Posted April 16, 2018 @Earthshine Thanks... I will download from this site, would this have impact on the code that I have written and resolve the issue im having? Thanks Hari
Earthshine Posted April 16, 2018 Posted April 16, 2018 (edited) I guess you should make sure you are running the latest AutoIT as well as the Scintilla editor made for it as well Edited April 16, 2018 by Earthshine My resources are limited. You must ask the right questions
HariKara Posted April 16, 2018 Author Posted April 16, 2018 @EarthshineI have the latest version of AutoIt downloaded on Friday Last week from AutoIT website. and the latest SCIEditor. THe XMLDOMWrapper is the one from the below link
Earthshine Posted April 16, 2018 Posted April 16, 2018 (edited) ok. good. those XML guru's can probably help you in that case. I'll do some more digging. I would assume you can update a key's value using the UDF, right? so make the value "" Edited April 16, 2018 by Earthshine My resources are limited. You must ask the right questions
Earthshine Posted April 16, 2018 Posted April 16, 2018 found this thread. looks like the example given as an solution could be modified for your purposes, remove the offending node and create a new one maybe? My resources are limited. You must ask the right questions
Subz Posted April 16, 2018 Posted April 16, 2018 Local $sFileName = @ScriptDir & "\Filename.xml" Local $oErrorHandler = ObjEvent("AutoIt.Error", "_XmlErrFunc") Local $oXMLDoc = ObjCreate("MSXML2.DOMDocument") $oXMLDoc.validateOnParse = False $oXMLDoc.load($sFileName) Local $oNode = $oXMLDoc.selectSingleNode('//configuration/userSettings/CP.Infrastructure.Properties.Settings/setting/value/dictionary/items/item[@key="LoginUsername"]') $oNode.Text = "" $oXMLDoc.save($sFileName) Func _XmlErrFunc($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
mLipok Posted April 16, 2018 Posted April 16, 2018 8 hours ago, HariKara said: THe XMLDOMWrapper is the one from the below link But I guess that you download old not recent version XML_1.1.1.13.zip. Earthshine 1 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now