Visit Our UNIX and Linux User Community

Parse XML e report con AWK

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Parse XML e report con AWK
# 1  
Old 03-29-2010
Parse XML e report con AWK

Thanks in advance who can answer.

I have to make a small shell that after reading an XML file and extract the fields I create a text file with the same fields taken previously in tabular form.

I did this
  for(i=2; i<=NF; i+=2) {
          if ( $i ~ /^\// ) continue
          printf("name->[%s] value->[%s]\n", $i, $(i+1))

name->[?xml version="1.0" encoding="UTF-8" standalone="no" ?] value->[]
name->[a1 Id="123456" Size="4249" isDir="false"] value->[]
name->[a2] value->[123456]
name->[a3] value->[123456]
name->[a4] value->[2010-03-22T16:17:09]

a shell that reading the outcome of the first (risultato.out) I create table


the report should be
a1                    a2                    a3               a4
                       123456              123456         123456

a third shell should check every now and then usually when I see the updated XML file and the field a1 (now empty) risultato.out open again and add the value in a1.

I do not write the last 2 shell.: (


Last edited by mcarlo65; 03-29-2010 at 05:24 PM.. Reason: awk xml shell
# 2  
Old 03-29-2010
English only, please read the forum rules, edit and translate your post!

As always, to help us understand your requirements, post some small representative sample input, not only the output you'd like to get,
given that input.

Thank you!

Last edited by radoulov; 03-29-2010 at 04:50 PM..

Previous Thread | Next Thread
Test Your Knowledge in Computers #67
Difficulty: Medium
IT security or cybersecurity controls are based on a combination of three types of security controls, (1) physical controls, (2) logical controls and (3) administrative controls.
True or False?

10 More Discussions You Might Find Interesting

1. Programming

How to write a java program that will parse through an XML file and generate a report?

I'm pretty new to Java and I am trying to write a program that will pick up a file from a windows directory adn parse through the XML file to produce a report that will show a total item count and a total paid amount. Any one have any suggestions? Trying to figure out where to start... (4 Replies)
Discussion started by: risarose87
4 Replies

2. Shell Programming and Scripting

awk Script to parse a XML tag

I have an XML tag like this: <property name="agent" value="/var/tmp/root/eclipse" /> Is there way using awk that i can get the value from the above tag. So the output should be: /var/tmp/root/eclipse Help will be appreciated. Regards, Adi (6 Replies)
Discussion started by: asirohi
6 Replies

3. Shell Programming and Scripting

Please Help with AWK to parse rapidly changing XML messages

Hi Guy's Can I please get some help with this code. I have xml feed file which rapidly changing temporary file and I need to capture the content of this file as soon as data arrives. Example of the data Required data output Time is current time. This is awk code that I have so far... (4 Replies)
Discussion started by: James_Owen
4 Replies

4. Shell Programming and Scripting

AWK to Parse XML messages

Hello Guys, Please help with AWK problem. I have XML file which contains a list of messages for subjects. Example of the messages: , message=, message=, message=, message=, message=, message=, message=, message= I want to use AWK to parse these xml messages but I am... (7 Replies)
Discussion started by: James_Owen
7 Replies

5. Shell Programming and Scripting

python - wget xml doc and parse with awk

Well, that's what I'd do in bash :) Here's what I have so far: import urllib2 from BeautifulSoup import BeautifulStoneSoup xml = urllib2.urlopen('') soup = BeautifulStoneSoup(xml) print soup.prettify() but all it does is grab the html... (0 Replies)
Discussion started by: unclecameron
0 Replies

6. Shell Programming and Scripting

Shell script (not Perl) to parse xml with awk

Hi, I have to make an script according to these: - I have couples of files like: xxxxxxxxxxxxx.csv xxxxxxxxxxxxx_desc.xml - every xml file has diferent fields, but keeps this format: ........ <defaultName>2011-02-25T16:43:43.582Z</defaultName> ........... (2 Replies)
Discussion started by: Pluff
2 Replies

7. 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

8. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies

9. Shell Programming and Scripting

Need AWk To parse XML logs

Hi , I need an Awk script to parse my log file . 2008-04-26 10:00:13,391 INFO Logger - <?xml version="1.0" encoding="UTF-8" standalone="no"?><2dm tmsg... (0 Replies)
Discussion started by: amit1_x
0 Replies

10. Shell Programming and Scripting

How to parse a XML file using PERL and XML::DOm

I need to know the way. I have got parsing down some nodes. But I was unable to get the child node perfectly. If you have code please send it. It will be very useful for me. (0 Replies)
Discussion started by: girigopal
0 Replies

Featured Tech Videos