amakrkr Posted March 24, 2013 Share Posted March 24, 2013 (edited) Delete it please. I have reopended new thread. Edited March 27, 2013 by amakrkr Link to comment Share on other sites More sharing options...
amakrkr Posted March 25, 2013 Author Share Posted March 25, 2013 Ok here is the partial working script i made so far #include<File.au3> Local $original_file = FileOpen(@ScriptDir & "\" & "original.xml",0) local $original_file_link = @ScriptDir & "\" & "original.xml" local $i = 1 Local $user_file = @ScriptDir & "\" & "created.xml" Local $aArray Local $aRecords _FileReadToArray($user_file, $aArray) While 1 Local $line = FileReadLine($original_file) If @error = -1 Then ExitLoop if $line = '<Att08>' then local $inner_line = $i For $x = 1 To $aArray [0] $inner_line = $i + $x _FileWriteToLine($original_file_link ,$inner_line ,$aArray[$x]) Next EndIf $i = $i+1 WEnd FileClose($original_file) Script works "fine" it inserts node to correct spot in target XML file but if i run script twice or more it just duplicates records under same node. What i would like is to delete node (with or with tags) and insert it again. So if user presses button twice it wont screw up XML. Link to comment Share on other sites More sharing options...
water Posted March 25, 2013 Share Posted March 25, 2013 In the Examples Script forum there is a XMLDOMWrapper UDF which might help you. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
amakrkr Posted March 25, 2013 Author Share Posted March 25, 2013 In the Examples Script forum there is a XMLDOMWrapper UDF which might help you. I have tried that but i couldn't get it to work. #include<File.au3> #include<_XMLDomWrapper.au3> Local $original_file = FileOpen(@ScriptDir & "\" & "original.xml",0) local $original_file_link = @ScriptDir & "\" & "original.xml" local $i = 1 Local $user_file = @ScriptDir & "\" & "created.xml" Local $aArray Local $aRecords _FileReadToArray($user_file, $aArray) While 1 Local $line = FileReadLine($original_file) If @error = -1 Then ExitLoop if $line = '<Att08>' then _XMLDeleteNode("/Targets/Att08") local $inner_line = $i For $x = 1 To $aArray [0] $inner_line = $i + $x _FileWriteToLine($original_file_link ,$inner_line ,$aArray[$x]) Next EndIf $i = $i+1 WEnd FileClose($original_file) Link to comment Share on other sites More sharing options...
water Posted March 25, 2013 Share Posted March 25, 2013 I'm not very firm with XML but "couldn't get it to work" doesn't even help those who know more and are willing to help. Please be more specific! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
amakrkr Posted March 25, 2013 Author Share Posted March 25, 2013 Well abvove script compiles fine without any errors but NODE is still there. Function does not delete it. Link to comment Share on other sites More sharing options...
water Posted March 25, 2013 Share Posted March 25, 2013 You have to do all processing of the XML file using functions from the UDF! _XMLFileOpen etc. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
amakrkr Posted March 27, 2013 Author Share Posted March 27, 2013 (edited) Hello, i am back with more question. So far i managed to open and properly read node i need and also delete it and insert new node. #include<_XMLDomWrapper.au3> #include<Array.au3> $formed_xml = @ScriptDir & "\" & "created.xml" $origin_xml = @ScriptDir & "\" & "original.xml" _SetDebug (True) _XMLFileOpen($origin_xml) $re = _XMLGetChildNodes("/Targets/Att08") _XMLDeleteNode("/Targets/Att08") _XMLCreateChildNode("/Targets","Att08") _XMLCreateChildWAttr("/Targets/Att08","Property","NAME","Inserted text 1") ; tested insert of a node I have fund a function _XMLCreateChildNode that will do just that but i have hard time figuring out parameters i needs to create XML node expecially in my case where i have information stored in seperate xml file. Edited March 27, 2013 by amakrkr Link to comment Share on other sites More sharing options...
water Posted March 27, 2013 Share Posted March 27, 2013 If you have solved the problem, can you please post the result as a reference for future users? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
amakrkr Posted March 27, 2013 Author Share Posted March 27, 2013 No i haven't solved it yet. Read the above post. Link to comment Share on other sites More sharing options...
water Posted March 27, 2013 Share Posted March 27, 2013 I see. You change the content of your posts My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted March 27, 2013 Share Posted March 27, 2013 It doesn't look like you can work with multiple XMLS files at a time. All functions use a single Global variable to access the XML file. So you need to process them in sequence. Open a file, grab all the needed information and store it in variables, open the second and copy the stored data. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
amakrkr Posted March 27, 2013 Author Share Posted March 27, 2013 Yes i just figured this out ... i am just wondering how many lines can i store in a variable .... lets say my other xml is 10k lines long ? Link to comment Share on other sites More sharing options...
water Posted March 27, 2013 Share Posted March 27, 2013 I think the only limit is memory. For easy processing decide if you want to store the XML file in a single variable or an array (using _FileReadToArray) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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