Sponsored Content
Full Discussion: XML format
Top Forums Shell Programming and Scripting XML format Post 302433617 by radoulov on Wednesday 30th of June 2010 06:07:01 AM
Old 06-30-2010
With Perl and XML::Simple:

Code:
perl -F\\t -MXML::Simple -lane'
  @keys = @F and next if $. == 1;
  %hash = ();
  $hash{$keys[$_]} = [$F[$_]] for 0..$#F;
  print XMLout(\%hash, RootName => "whatever");
  ' infile

Which produces:
Code:
zsh-4.3.10[t]% perl -F\\t -MXML::Simple -lane'
quote>   @keys = @F and next if $. == 1;
quote>   %hash = ();
quote>   $hash{$keys[$_]} = [$F[$_]] for 0..$#F;
quote>   print XMLout(\%hash, RootName => "whatever");
quote>   ' infile
<whatever>
  <'Average Time'>1.39</'Average Time'>
  <'Date'>2010-06-02</'Date'>
  <'ID'>3</'ID'>
  <'Name'>30943</'Name'>
  <'Time'>00:00:50</'Time'>
</whatever>

<whatever>
  <'Date'>2010-06-02</'Date'>
  <'ID'>1</'ID'>
  <'Name'>4545</'Name'>
  <'Time'>00:01:03</'Time'>
</whatever>

<whatever>
  <'Date'>2010-06-02</'Date'>
  <'ID'>9</'ID'>
  <'Name'>8203</'Name'>
  <'Time'>00:01:00</'Time'>
</whatever>

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

format xml

i want to grep to a file the numerator-denominator, 1.23456, 1.78901 from the following xml tags. <locks:pair xc:value="numerator/denominator" xc:type="Fields"> <mp:formFactor>1</mp:formFactor> <mp:quotation>numerator-denominator</mp:quotation> <mp:one>1.23456</mp:one>... (5 Replies)
Discussion started by: sigh2010
5 Replies

2. Shell Programming and Scripting

Convert XML to CSV format

Can any one give the idea on this, please. I have the following XML file and wants to convert into CSV(comma separated value) format. <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE Waveset PUBLIC 'waveset.dtd' 'waveset.dtd'> <Waveset> <Object name='ra8736'> <Attribute name='ADDRESS'... (2 Replies)
Discussion started by: kumar04
2 Replies

3. Shell Programming and Scripting

how to parse the file in xml format using awk/nawk

Hi All, I have an xml file with the below format. <a>111</a><b>222</b><c>333<c><d><e>123</e><f>234</f><d><e>456</e><f>789</f> output needed is 111,222,333,123,234 111,222,333,456,789 nawk 'BEGIN{FS="<|>"} {print a,b,c,e,f a="" ... (7 Replies)
Discussion started by: natalie23
7 Replies

4. UNIX for Dummies Questions & Answers

XML / XSD: what is a good format for amounts?

Suppose I have a XSD definition of amount: <xs:element name="Amount" type="amount> And the amounts themselves are given in the following format in the XML: <amount>1.000.00</amount> In other words, the thousand separator and the decimal point are the same. Does this require that the parser... (3 Replies)
Discussion started by: figaro
3 Replies

5. Shell Programming and Scripting

Need to split a xml file in proper format

Hi, I have a file which has xml data but all in single line Ex - <?xml version="1.0"?><User><Name>Robert</Name><Location>California</Location><Occupation>Programmer</Occupation></User> I want to split the data in proper xml format Ex- <?xml version="1.0"?> <User> <Name>Robert</Name>... (6 Replies)
Discussion started by: avishek007
6 Replies

6. Shell Programming and Scripting

XML dateTime format in shell script

How can i frame current date & time in the xml standard dateTime format in shell script 2011-10-18T12:00:00.000000 I got up to the date format using the below code date '+%Y'-'%m'-'%d'T ---------- Post updated at 09:10 AM ---------- Previous update was at 08:53 AM ---------- ... (6 Replies)
Discussion started by: vel4ever
6 Replies

7. Shell Programming and Scripting

From sql Insert Query to XML format

Hi How do I translate Let say Cat inserts.sql gives Insert into PM9_TAXATION_ROUNDING (STATE_GECODE, TAX_TYPE, TAX_AUTHORITY, SYS_CREATION_DATE, SYS_UPDATE_DATE, APPLICATION_ID, DL_SERVICE_CODE, ROUNDING_METHOD) Values ('xx', 'xx', 'x', TO_DATE('10/26/2012 13:01:20',... (3 Replies)
Discussion started by: anuj87in
3 Replies

8. Shell Programming and Scripting

How can I replace data in between xml tags to required format?

Hi All, I have a requirement to change the data in xml file to required format. Below is the scenario. Please find the attached Xml file which contains data that I need to convert.. <ReleaseIndicatorList><ReleaseIndicator>Alternative... (0 Replies)
Discussion started by: Prathyu
0 Replies

9. Shell Programming and Scripting

Convert tag based lines to xml format

Hi All, Can some one help me to convert this line of code to xml format. Thanks in advance, preethy. input: ... (2 Replies)
Discussion started by: preethy
2 Replies
All times are GMT -4. The time now is 04:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy