Jump to content

Recommended Posts

Posted

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.

Posted

In the Examples Script forum there is a XMLDOMWrapper UDF which might help you.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (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 by amakrkr
Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I see. You change the content of your posts :wacko:

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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 ?

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
×
×
  • Create New...