Hi everyone,
I have an xml file with a list of articles. To be able to import it i have to change names and delete some entries. That part has been no problem (did it using sed).
Now I'm stuck because i have to duplicate an entry and change the name.
The original file looks like this:
Code:
<PRODUKT>
<ARTIKELNUMMER>00001</ARTIKELNUMMER>
<PREIS>100.00</PREIS>
</PRODUKT>
<PRODUKT>
<ARTIKELNUMMER>00002</ARTIKELNUMMER>
<PREIS>200.00</PREIS>
</PRODUKT>
<PRODUKT>
<ARTIKELNUMMER>00003</ARTIKELNUMMER>
<PREIS>300.00</PREIS>
</PRODUKT>
I have to duplicate the entry "Artikelnummer" and change the name, value stays the same.
So the result have to look like this:
Code:
<PRODUKT>
<ARTIKELNUMMER>00001</ARTIKELNUMMER>
<NEWENTRY>00001</NEWENTRY>
<PREIS>100.00</PREIS>
</PRODUKT>
<PRODUKT>
<ARTIKELNUMMER>00002</ARTIKELNUMMER>
<NEWENTRY>00002</NEWENTRY>
<PREIS>200.00</PREIS>
</PRODUKT>
<PRODUKT>
<ARTIKELNUMMER>00003</ARTIKELNUMMER>
<NEWENTRY>00003</NEWENTRY>
<PREIS>300.00</PREIS>
</PRODUKT>
Whenever i try to grab the value, put it in a variable and insert it, i endet up adding one line at the bottom of the file. It's my first time editing xml, hope someone can help me.
The script is supposed to run on an Ubuntu Server and if possible I'd like to use built in commands without installing too much stuff.
Thanks in advance!
Effman