DanAutomator Posted July 15, 2013 Share Posted July 15, 2013 I was recently tasked with pulling some data from older XML files we inherited to populate our database with. In particular I wish to be able to parse the XML below in Autoit, get the value for "DataUploadCompleted", write that value to an INI file which can then be processed by our Systems Management tool and inserted into it's database. I cannot parse XML directly with the Systems Management tool so was hoping Autoit would be a quick solution. Anyone able to give me some ideas on the best way to go about this... In the past the XML files I have parsed were all rather easy to locate the Xpath for and pull data from, but I can't figure out the best way to do so with the format of this one... Here's the XML code: <?xml version="1.0"?> <Variables Version="0"> <Variable Name="DataUploadDays" Value="Sun,Mon,Tue,Wed,Thu,Fri,Sat"/> <Variable Name="DataUploadStart" Value="20"/> <Variable Name="DataUploadEnd" Value="21"/> <Variable Name="DataUploadRandom" Value="1/1/2011 0:00:00 AM"/> <Variable Name="DataUploadRandomSuccessWindow" Value="1,0"/> <Variable Name="DataUploadRandomFailedWindow" Value="1,0"/> <Variable Name="DataUploadStarted" Value="1/1/2011 0:00:00 AM"/> <Variable Name="DataUploadCompleted" Value="1/1/2011 0:00:00 AM"/> <Variable Name="DataUploadStatus" Value="Pending" Result="" DateTime="1/1/2011 0:00:00 AM"/> <Variable Name="DataDownloadDays" Value="Sun,Mon,Tue,Wed,Thu,Fri,Sat"/> <Variable Name="DataDownloadStart" Value="04"/> <Variable Name="DataDownloadEnd" Value="05"/> <Variable Name="DataDownloadRandom" Value="1/1/2011 0:00:00 AM"/> <Variable Name="DataDownloadRandomSuccessWindow" Value="1,0"/> <Variable Name="DataDownloadRandomFailedWindow" Value="1,0"/> <Variable Name="DataDownloadStarted" Value="1/1/2011 0:00:00 AM"/> <Variable Name="DataDownloadCompleted" Value="1/1/2011 0:00:00 AM"/> <Variable Name="DataDownloadStatus" Value="Pending" Result="" DateTime="1/1/2011 0:00:00 AM"/> </Variables> Link to comment Share on other sites More sharing options...
Solution blckpythn Posted July 15, 2013 Solution Share Posted July 15, 2013 (edited) Something I know how to do! Try the following. You need the >_XMLDomWrapper.au3 #include <_XMLDomWrapper.au3> _XMLFileOpen(@DesktopDir & "\test.xml") $value = _XMLGetAttrib('//Variables/Variable[@Name="DataUploadCompleted"]', 'Value') IniWrite("c:\pathtoini\myinifile.ini", "Sectionname", "datauploadkeyname", $value) Or shortened to #include <_XMLDomWrapper.au3> _XMLFileOpen(@DesktopDir & "\test.xml") IniWrite("c:\pathtoini\myinifile.ini", "Sectionname", "datauploadkeyname", _XMLGetAttrib('//Variables/Variable[@Name="DataUploadCompleted"]', 'Value')) Edited July 15, 2013 by blckpythn 0xdefea7 1 Link to comment Share on other sites More sharing options...
DanAutomator Posted July 15, 2013 Author Share Posted July 15, 2013 Thanks a ton blckpythn! I have been trying to get it to run all day, and even with your help I was still getting an error while compiling (incorrect syntax, and unexpected number of arguments). I finally decided to try it on my own computer instead of my work laptop and it compiled and works just fine. Link to comment Share on other sites More sharing options...
blckpythn Posted July 16, 2013 Share Posted July 16, 2013 Happy to help! Link to comment Share on other sites More sharing options...
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