lsaas
September 17, 2009, 10:55am
1
Hi everybody,
I have two XML files.
I am working on a script that could copy and paste the contents of the first xml file to the desired location in the second xml file.
Here is my first XML file.
This is the second XML file.
<?xml version="1.0" encoding="utf-8"?><SchedulerState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd="XML Schema ">
<Actions/>
<Macros>
<Macro>
<Pause>250</Pause>
<Position>0</Position>
<Name>New Macro</Name>
<MacroActions>
<MacroAction xsi:type="SignalAction">
<Pause>250</Pause>
<Position>0</Position>
<IROutputLocation xsi:type="RedRat3LocationInfo">
<Description>tested RedRat</Description>
<Name>changement_location</Name>
<SerialNo>2329</SerialNo>
</IROutputLocation>
<DeviceName>Premiere</DeviceName>
The contents of the first file have to appear here.
</MacroAction>
</MacroActions>
</Macro>
</Macros>
</SchedulerState>
Finaly, I wnat to obtain something like that :
<?xml version="1.0" encoding="utf-8"?><SchedulerState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd="http://www.w3.org/2001/XMLSchema ">
<Actions/>
<Macros>
<Macro>
<Pause>250</Pause>
<Position>0</Position>
<Name>New Macro</Name>
<MacroActions>
<MacroAction xsi:type="SignalAction">
<Pause>250</Pause>
<Position>0</Position>
<IROutputLocation xsi:type="RedRat3LocationInfo">
<Description>tested RedRat</Description>
<Name>changement_location</Name>
<SerialNo>2329</SerialNo>
</IROutputLocation>
<DeviceName>Premiere</DeviceName>
<Signal xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd="http://www.w3.org/2001/XMLSchema " xsi:type="ModulatedSignal">
<Name>P+</Name>
<UID>9a4MvZXb2UWM99drxGUxAg==</UID>
<ModulationFreq>55555</ModulationFreq>
<Lengths>
<double>0.21425</double>
<double>0.43574999999999997</double>
<double>0.32475</double>
<double>0.31925</double>
<double>0.22075</double>
<double>0.10625</double>
<double>0.545</double>
<double>0.64825</double>
<double>0.20975</double>
</Lengths> <SigData>AAEAAgMEBQYABAAEAAQDAgUHBX8AAQgCAwQFBggECAIFBAMCBQcFfw==</SigData>
<NoRepeats>2</NoRepeats>
<IntraSigPause>92.769</IntraSigPause>
<ToggleData/>
</Signal>
</MacroAction>
</MacroActions>
</Macro>
</Macros>
</SchedulerState>
I think it is possible with awk but another solution will do it too.
Thanks, Ludo
rdcwayx
September 18, 2009, 3:01am
2
sed '/<\/DeviceName>/r first.xml' second.xml
lsaas
September 18, 2009, 5:48am
3
Thank you very much, it solved my problem !