Insert Text in Second Last Line of .xml
Posted: 25 Jan 2022 21:54
I have an xml file with <menu> </menu> opening\closing tags.
I want to add lines of text before the last line (the closing </menu> tag).
example:
<?xml version="1.0"?>
<menu>
<header>
<listname>PC Games</listname>
<lastlistupdate>10/09/2021</lastlistupdate>
<listversion>0.1</listversion>
</header>
<game name="Streets of Rage 4" index="true" image="0">
<description>Streets of Rage 4</description>
<manufacturer>Dotemu</manufacturer>
<year>2020</year>
<genre>Beat-'Em-Up</genre>
<score>0.85</score>
<players>4</players>
<enabled>Yes</enabled>
</game>
</menu>
I want to add more games (all the info between the <game> tags), I can handle the echo >> part, i just dont know how to echo it above the </menu> line.
Any help is appreciated thanks.
I want to add lines of text before the last line (the closing </menu> tag).
example:
<?xml version="1.0"?>
<menu>
<header>
<listname>PC Games</listname>
<lastlistupdate>10/09/2021</lastlistupdate>
<listversion>0.1</listversion>
</header>
<game name="Streets of Rage 4" index="true" image="0">
<description>Streets of Rage 4</description>
<manufacturer>Dotemu</manufacturer>
<year>2020</year>
<genre>Beat-'Em-Up</genre>
<score>0.85</score>
<players>4</players>
<enabled>Yes</enabled>
</game>
</menu>
I want to add more games (all the info between the <game> tags), I can handle the echo >> part, i just dont know how to echo it above the </menu> line.
Any help is appreciated thanks.