How to get input xml file as XMLout. output.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get input xml file as XMLout. output.
# 1  
Old 04-06-2010
How to get input xml file as XMLout. output.

Hi ,
I am trying to get an reference of a XML formatted data using XML::Simple::XMLin

and again trying to retrive the XML data as it was before using XML::Simple::XMLout.

But finding a deviation in the format can any pls help me out.

Input file sr.xml
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<scenario>
<counter>
  <counterdef name="HbH-counter" init="1000"> </counterdef>
  <counterdef name="EtE-counter" init="2000"> </counterdef>
  <counterdef name="session-counter" init="10005"> </counterdef>
</counter>
</scenario>

perl code
Code:
 my $data='';
 $file_to_parse='sr.xml';
 my $xml = new XML::Simple;
 my $config = eval { XML::Simple::XMLin("$file_to_parse") };
 $data = $xml->XML::Simple::XMLin("$file_to_parse",keeproot => 1);
 print $xml->XMLout($data,outputfile =>'/var/tmp/Call',keeproot => 1);

outputfile('/var/tmp/Call')
Code:
<scenario>
  <counter name="counterdef">
    <EtE-counter init="2000" />
    <HbH-counter init="1000" />
    <session-counter init="10005" />
  </counter>
</scenario>

My expectation was as it was before :
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<scenario>
<counter>
  <counterdef name="HbH-counter" init="1000"> </counterdef>
  <counterdef name="EtE-counter" init="2000"> </counterdef>
  <counterdef name="session-counter" init="10005"> </counterdef>
</counter>
</scenario>


Last edited by Yogesh Sawant; 04-06-2010 at 04:18 AM.. Reason: added code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to reformat output if input file is empty, but not if file has data in it

The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format: input chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18 chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. Shell Programming and Scripting

Read xml file till script finds separation and run again for next input and so on

Hi All, I have one query, I managed to run script with user inputs through command line or with 1 file. But I need to read a txt file/xml file in which user can mention multiple sets of answers and script should run for each set till it reach the EOF. Thanks in advance for example, the file... (3 Replies)
Discussion started by: rv_champ
3 Replies

3. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies

4. Shell Programming and Scripting

XML variable for input in same input file

Dear All , i stuck in one problem executing xml .. i have input xml as <COMMAND name="ARRANGEMENT.WRITE" timestamp="0" so="initial"> <SVLOBJECT> <LONG name="CSP_PMNT_ID" val="-1"/> <MONEY name="CSP_CEILING" amount="0.0" currency="AUD"/> ... (6 Replies)
Discussion started by: arvindng
6 Replies

5. Shell Programming and Scripting

Help in parsing XML output file in perl.

Hi I have an XML output like : <?xml version="1.0" encoding="ISO-8859-1" ?> - <envelope> - <body> - <outputGetUsageSummary> - <usgSumm rerateDone="5"> - <usageAccum accumId="269" accumCaptn="VD_DP_AR" inclUnits="9999999.00" inclUnitsUsed="0.00" shared="false" pooled="false"... (7 Replies)
Discussion started by: rkrish
7 Replies

6. Shell Programming and Scripting

Output as XML File

Hello All, I am running a shell script, which in turn runs a perl script. When this perl script runs successfully, the output is generated as an XML file. The following is a snippet of my code: .... .... ... if ; then perl myScript.pl echo "<statistics>" echo "... (2 Replies)
Discussion started by: ad23
2 Replies

7. UNIX for Dummies Questions & Answers

12. If an ‘88’ Record with BAI Code ‘902’ was found on input file and not written to Output file, re

This is my input file like this 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+00000000354,,/ 49,+00000000000416920,00002/ 03,5313236,,015,+00231036992,,,045,+00231036992,,,901,+00000048428,,/ 88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/ 88,902,+0000000079077,,/... (0 Replies)
Discussion started by: sgoud
0 Replies

8. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

9. Shell Programming and Scripting

input -output file

Hi, I am having an Input file .which is having a list of names. comapring with our database , needs to write the out put in file called output.txt , format should be name--> country--->phone number could you please help me.. thanks in advance (7 Replies)
Discussion started by: hegdeshashi
7 Replies

10. Shell Programming and Scripting

Remove xmlns from xml output file

Hi, I have the xml output file which contents the namespace xmlns. I would like to remove that line <AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Table1> <Data1 10 </Data1> <Data2 20 </Data2> <Data3 40 </Data3> <Table1> </AutoData> I would like to remove line... (1 Reply)
Discussion started by: ca_sr2274
1 Replies
Login or Register to Ask a Question