Sponsored Content
Top Forums Shell Programming and Scripting Creating a larger .xml file from a template(sample file) Post 302721841 by spacebar on Friday 26th of October 2012 12:19:25 AM
Old 10-26-2012
Check out the below example, you should be able to modify it to do what you want:
Code:
$ cat t
STRING1
STRING2
STRING3
STRING4


## perl script
print "....Some---Header....... ## Must preserve all the header tags\n";
open ( STRINGS, "</temp/tmp/t") or die ("***Error- Couldn't open file: C:/temp/tmp/t, $!\n");
while ( <STRINGS> ) {
  chomp;
  print "<SignalPreference>\n";
  print "        ...   #Must preserve this part as it is\n";
  print "        <SignalName>$_</SignalName>\n";
  print "        ...  #Must preserve this part as it is\n";
  print "</SignalPreference>\n";
  print "\n";
  print "......Some formatting text.......   ### must Preserve this as it is\n";
}
close STRINGS;
print "....Some footer text......  ### Must preserve this as it is.\n";


$ test.pl
....Some---Header....... ## Must preserve all the header tags
<SignalPreference>
        ...   #Must preserve this part as it is
        <SignalName>STRING1</SignalName>
        ...  #Must preserve this part as it is
</SignalPreference>

......Some formatting text.......   ### must Preserve this as it is
<SignalPreference>
        ...   #Must preserve this part as it is
        <SignalName>STRING2</SignalName>
        ...  #Must preserve this part as it is
</SignalPreference>

......Some formatting text.......   ### must Preserve this as it is
<SignalPreference>
        ...   #Must preserve this part as it is
        <SignalName>STRING3</SignalName>
        ...  #Must preserve this part as it is
</SignalPreference>

......Some formatting text.......   ### must Preserve this as it is
<SignalPreference>
        ...   #Must preserve this part as it is
        <SignalName>STRING4</SignalName>
        ...  #Must preserve this part as it is
</SignalPreference>

......Some formatting text.......   ### must Preserve this as it is
....Some footer text......  ### Must preserve this as it is.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sample Unix script file to convert .xml to .csv

Dear all, Can you send me a script file the changes .xml to .csv file. Thanks, Srinivasa (4 Replies)
Discussion started by: srinivasaphani
4 Replies

2. Shell Programming and Scripting

Need help in creating a Unix Script to parse xml file

Hi All, My requirement is create an unix script to parse the xml file and display the values of the Elements/value between the tags on console. Like say, I would like to fetch the value of errorCode from the below xml which is 'U007' and display it. Can we use SED command for this? I have tried... (10 Replies)
Discussion started by: Anil.Wmg
10 Replies

3. UNIX for Dummies Questions & Answers

How to find a file whick is consuming larger disk space in file system

Hello, Can anybody please tell me the command to find out the filesystem or a file which is consuming larger disk space sing i want to find out the file and want to compress it please help me out any help would be appreciated (6 Replies)
Discussion started by: lokeshpashine
6 Replies

4. Shell Programming and Scripting

xmlstarlet template parse small xml file

I have a file like: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <geonames> <geoname> <toponymName>Palos Verdes</toponymName> <name>Palos Verdes</name> <lat>42.1628912</lat> <lng>-123.6481235</lng> <geonameId>5718340</geonameId> <countryCode>US</countryCode>... (4 Replies)
Discussion started by: unclecameron
4 Replies

5. UNIX for Advanced & Expert Users

Can someone help me with creating RPM sample i need ?

i know there are tons n tons of documentation out there to help me out to understand this.. but wen i read it, its to confusing for me.. i would really wish a kind hearted person on this forum can come out with a sample spec file for the example steps that i need for the RPM. This will make me... (0 Replies)
Discussion started by: bladez
0 Replies

6. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

7. Shell Programming and Scripting

Add column info from one file to larger second file

Hi, long time reader, first time poster. I've done some searching so please if this is a repeated post excuse the duplicate, but what I have are two files roughly like so: File 1: A W B X C Y D Z File 2: A 1 C 2 D 3 And what I would like to get out is... (4 Replies)
Discussion started by: wallysb01
4 Replies

8. Shell Programming and Scripting

Creating multiple xml tag lines in a file

Hi All, Can someone tell me how can we create same xml tag lines based on the number of lines present in other file and replace the Name variable vaule present in other file. basically I have this xml line <typ:RequestKey NameType="RIC" Name="A1" Service="DDA"/> and say I... (4 Replies)
Discussion started by: Optimus81
4 Replies

9. UNIX for Dummies Questions & Answers

XML File Generation - Template Help

Hi, I have hit a bit of a brick wall.:confused: need the following code edited: echo "<?xml version=\"1.0\"?><dailyBalance_ROWSET>" > ${DataDir}/${extract_script}${ApplicationDate}.${Suffix} RunSQL ${extract_script} ${ActionFlag} echo "</dailyBalance_ROWSET>" >>... (2 Replies)
Discussion started by: Xergxes7
2 Replies

10. Shell Programming and Scripting

Inputing info from a CSV file and filling a template file

Hi, I have a .csv file that contains a variety of fields for 60 clients: USERNAME, PASSWORD, and COMMENTS. I have a template file which contains a great deal of data for each client and has the fields USERNAME, PASSWORD, and COMMENTS that has to be filled with the values of USERNAME,... (1 Reply)
Discussion started by: mojoman
1 Replies
MUSETUP-GTK(1)							Museek Daemon Plus						    MUSETUP-GTK(1)

NAME
Musetup-GTK - PyGTK2 Configuration app for Museekd SYNOPSIS
musetup-gtk [-c | --config <config-filename>] [-h | --help] DESCRIPTION
Musetup-GTK is PyGTK2 GUI that configures museekd(1). There are two configuration modes: Dialogs - under General Settings - that provide the most commonly configured options, including the adding of shared directories, via a muscan frontend (add/removing & rescanning take effect immediately). The Settings Tree allows you to modify all options and even remove entire settings nodes, so it is quite dangerous, and should be used with much care. After changes to settings you need to Save them from them be written to the config file. OPTIONS
Musetup-GTK accepts the following options: -c, --config <config-filename> Selected Config's path and filename. -h, --help Display Help and exit. EXAMPLE
To run this program the standard way type: musetup-gtk Alternativly you use a different config file with: musetup-gtk -c config.xml FILES
~/.museekd/config.xml The default location for the museekd config file. /usr/share/museek/museekd/config.xml.tmpl Config file template that's used if no config exists. AUTHORS
Code taken from musetup by Hyriand <hyriand@thegraveyard.org> daelstorm <daelstorm@gmail.com> SEE ALSO
mucous(1) mulog(1) murmur(1) muscan(1) muscand(1) museekcontrol(1) museekd(1) museeq(1) musetup(1) daelstorm Release 0.2.0 MUSETUP-GTK(1)
All times are GMT -4. The time now is 03:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy