![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
help xml
Group, Code:
$ cat 2233
12236 ID2
12239 ID3
Please guide me to construct the following XML from the above input.
<Comp>
<main>
<hlp fS="12236" eS="12237">
<std no="2233" />
<id="ID2"/>
</hlp>
<hlp fS="12239" eS="12240">
<std no="2233" />
<id="ID3"/>
</hlp>
</main>
</Comp>
** eS is +1 of fS value
** std no is the file name
|
|
||||
|
What have you tried, which parts are you having issues with? Do you have a preference for a particular implementation language?
(Isn't it a tad moronic to have a field value which is always another field value plus one?) |
|
||||
|
perl
hi try below perl scirpt say the script name is a.pl, below command can address your issue. Quote:
Code:
format STDOUT_TOP =
<Comp>
<main>
.
format STDOUT =
<hlp fs="@<<<<" es="@<<<<">
$text1 $text2
<std no="@<<<"/>
$text3
<id="@<<"/>
$text4
</hlp>
.
$file=shift;
open(FH,"<$file") or die "Can not open file";
while(<FH>){
@arr=split(" ",$_);
$text1=$arr[0];
$text2=$arr[0]+1;
$text3=$file;
$text4=$arr[1];
write;
}
print " </main>\n";
print "</Comp>\n";
close(FH);
|
|
||||
|
Era, thanks for replying. I tried for only one entry in the input file; something like this Code:
....
FILE=$1
fS=$(awk '{print $1}' $FILE)
((eS=fS+1))
echo "<Comp>" >> myxml
...
...
But I am not able to do the same if num entries in the input file in more than 1. Please help. |
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|