Help needed in writing awk script for xml source


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in writing awk script for xml source
# 1  
Old 09-24-2007
Question Help needed in writing awk script for xml source

Hi, i am not able to get an approach for converting xml file to flat file using awk programming. Can anyone help me out.

The input xml is like this:

<outer>
<field1>one</field1>
<field2>two</field2>
<field3>three<Error Code=777 Description=12345/></field3>
<field4>four</field4>
</outer>


Expected output is like this:

field1 field2 field3 field4 Code Description
one two three four 777 12345

The field1, field2, ... should not be hardcoded.

Thanks in advance,
Naren
# 2  
Old 09-24-2007
Not sure if this is a similar post to this ?

https://www.unix.com/unix-for-dummies...flat-file.html
# 3  
Old 09-24-2007
Quote:
Originally Posted by matrixmadhan
Not sure if this is a similar post to this ?

https://www.unix.com/unix-for-dummies...flat-file.html
Yes, both the posts looks very similar and they come from the same IP. I have a feeling it is a homework question.

Closing this thread and the other one.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing xml from excel sheet .xls using perl script

Hi all. I am working on the below requirement of generating .xml file from .xls file which i have , can someone please help me or in writing the perl script for the same: The xls file format is as below which has two columns and number of rows are not fixed: Fixlet Name ... (12 Replies)
Discussion started by: omkar.jadhav
12 Replies

2. Shell Programming and Scripting

Help needed for parsing large XML with awk.

My XML structure looks like: <?xml version="1.0" encoding="UTF-8"?> <SearchRepository> <SearchItems> <SearchItem> ... </SearchItem> <SearchItem> ... ... (1 Reply)
Discussion started by: jasonjustice
1 Replies

3. Shell Programming and Scripting

Help needed in writing a menu driven script

Hi, I was wondering if someone could help me write a shell script in Linux that backsup/restores data to anywhere I choose but it needs to be menu driven? Thanks, I'm new to Linux/Unix but liking it so far...just hoping to get to grips with the scripts! :) (7 Replies)
Discussion started by: Nicole
7 Replies

4. Shell Programming and Scripting

I need script to get xml access export from source server

Hi, I need a shell script to create to get XML access export from the source server. Thanks in Advance (3 Replies)
Discussion started by: bcb
3 Replies

5. Shell Programming and Scripting

help needed in writing a script

when i run a command the output is something like this: #3136 0.872914 01/17/08 22:06:36 #24817 1.231532 01/18/08 05:00:44 #15371 1.291679 01/18/08 03:00:08 #21279 2.130480 01/18/08 04:03:16 #7835 27.892056 01/18/08 00:01:32 i need to check if any one of the second column is... (5 Replies)
Discussion started by: cybersandex
5 Replies

6. Shell Programming and Scripting

Parsing xml using awk - more help needed

As per another thread - https://www.unix.com/shell-programming-scripting/81027-how-can-i-parse-xml-file-2.html I am using the following to extract the Subaccid and RecAccTotal from the xm file below awk -v v=SubaccId -F'' '$2==v{s=$3;getline;a+=$3}END {for (i in a)print v,i,a}' file Can... (6 Replies)
Discussion started by: frustrated1
6 Replies

7. Shell Programming and Scripting

needed help in writing a script!

Hi all, I needed help in writing a script for the following question.please help. Non-recursive shell script that accepts any number of arguments and prints them in the Reverse order. (For example, if the script is named rargs, then executing rargs A B C should produce C B A on... (5 Replies)
Discussion started by: wrapster
5 Replies

8. Shell Programming and Scripting

Help needed for writing a script

I have a requirement to write a script to get the number of errors generated during a time period. How can I achieve this. To be exact, I need to get the number of 404 or 500 errors generated during a time period from 01 to 02 hrs from a webserver access log. Any help will be appreciated.... (4 Replies)
Discussion started by: sriram_1978
4 Replies

9. Shell Programming and Scripting

plz help in writing awk script

hi buddies pls help in this matter i have file like this input file -------------------------- (PARTITION PARTITION_1 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_1 ,PARTITION PARTITION_2 VALUES LESS THAN (101, 32766 ) TABLESPACE PART_2 ,PARTITION PARTITION_3 VALUES LESS THAN (101,... (3 Replies)
Discussion started by: LAKSHMI NARAYAN
3 Replies

10. Shell Programming and Scripting

hi help in writing awk script(urgently)

hi to all i have file like this file.txt this is naryana expect hyderabad is a cool place now climate VISAKHSAPATNAM became very cool #vizag is my birth place #hyderabad is a cool place #now climate of hyd became very cool #vizag is my birth place #hyderabad is a cool place ... (7 Replies)
Discussion started by: LAKSHMI NARAYAN
7 Replies
Login or Register to Ask a Question