So work gave me a project. I'm a novice programmer at best (just enough to pass the two Java Programming courses required by my degree), and I'm more of a hardware and troubleshooting guy. So I'm here asking for some assistance.. bacon needs saving here... I'm trying to edit this XML File, specifically the tags /accounts/a0/name and /accounts/a0/jid.
I need to edit the text of /accounts/a0/name to be the username currently logged onto the windows machine, and the text of /accounts/a0/jid to read <username>@abc.123.com. I need the script to make these changes, then reach out and start an executable in the program files. This is what I have so far.Code:<!DOCTYPE accounts> <accounts version="0.14" xmlns="http://psi-im.org/options"> <accounts> <a0> <tls> <override-certificate type="QByteArray"> </override-certificate> <override-domain type="QString"> </override-domain> </tls> <custom-auth> <use type="bool">false</use> <authid type="QString"> </authid> <realm type="QString"> </realm> </custom-auth> <log type="bool">true</log> <use-host type="bool">false</use-host> <stun-port type="QString">3478</stun-port> <security-level type="int">0</security-level> <port type="int">5222</port> <ignore-SSL-warnings type="bool">false</ignore-SSL-warnings> <keep-alive type="bool">true</keep-alive> <connect-after-sleep type="bool">true</connect-after-sleep> <pgp-secret-key-id type="QString"> </pgp-secret-key-id> <name type="QString">Default</name> <ssl type="QString">auto</ssl> <reconn type="bool">true</reconn> <proxy-id type="QString"> </proxy-id> <bytestreams-proxy type="QString"> </bytestreams-proxy> <priority type="int">5</priority> <jid type="QString">default@abc.123.com</jid> <resource type="QString">Psi</resource> <password type="QString"> </password> <compress type="bool">false</compress> <automatic-resource type="bool">true</automatic-resource> <legacy-ssl-probe type="bool">true</legacy-ssl-probe> <require-mutual-auth type="bool">false</require-mutual-auth> <enabled type="bool">true</enabled> <auto type="bool">true</auto> <allow-plain type="QString">over encryped</allow-plain> <stun-host type="QString"> </stun-host> <host type="QString"> </host> </a0> </accounts> </accounts>
I've not had luck with code to set the text, and everything I have tried to save the file ends up with a blank file. I would appriciate any assistance you could offer.Code:Dim strPsiUser Set oWshShell = WScript.CreateObject ("WScript.Shell") strPsiUser = oWshShell.ExpandEnvironmentStrings ("%UserName%") Set xmlDoc = _ CreateObject("Microsoft.XMLDOM") xmlDoc.Async = "False" xmlDoc.Load("C:\My Documents\accounts.xml") xmlDoc.Save "C:\My Documents\accounts.xml"
Thank You!


Reply With Quote
