Need row number with Xml tags value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need row number with Xml tags value
# 1  
Old 06-11-2013
Need row number with Xml tags value

Hi,
Need help.
My source file contain data like:
HTML Code:
1       <?xml version="1.0"?> <Status>EGZAAE09</Status><Perform>002</Perform><DATE>2013-05-27</DATE>
1       <?xml version="1.0"?> <Status>ECBAE09</Status><Perform>002</Perform><DATE>2013-05-27</DATE>
2       <?xml version="1.0"?> <Status>Y78ZAAE08</Status><Perform>002</Perform><DATE>2013-05-27</DATE>
3       <?xml version="1.0"?> <Status>TRE8ZA9</Status><Perform>002</Perform><DATE>2013-05-27</DATE>
I need only <Status> value which is i'm getting with below command:
Code:
perl -nle 'print /(?<=Status>).*?(?=<\/Status>)/g' File_Name

Output is :
EGZAAE09
ECBAE09
Y78ZAAE08
TRE8ZA9

But i want row number also like:
HTML Code:
1	EGZAAE09
1	ECBAE09
2	Y78ZAAE08
3	TRE8ZA9
Pls help me to get this
# 2  
Old 06-11-2013
with awk

Code:
awk -F "  +|<Status>|</Status>" '{ print $1, $3}'

# 3  
Old 06-11-2013
This way is often used to remove html/xml tags.
Code:
awk '{gsub(/<[^>]*>/, " ");print $1,$2}'

# 4  
Old 06-11-2013
If for some reason, you need perl only syntax, this will do

Code:
perl -nle 'print /(.+(?=\<\?xml version="1.0"\?\>))|((?<=\<Status\>).+(?=\<\/Status\>))/g' file_name

This User Gave Thanks to rajamadhavan For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read row number from 1 file and print that row of second file

Hi. How can I read row number from one file and print that corresponding record present at that row in another file. eg file1 1 3 5 7 9 file2 11111 22222 33333 44444 55555 66666 77777 88888 99999 (3 Replies)
Discussion started by: Abhiraj Singh
3 Replies

2. Shell Programming and Scripting

Get row number from file1 and print that row of file2

Hi. How can we print those rows of file2 which are mentioned in file1. first character of file1 is a row number.. for eg file1 1:abc 3:ghi 6:pqr file2 a abc b def c ghi d jkl e mno f pqr ... (6 Replies)
Discussion started by: Abhiraj Singh
6 Replies

3. UNIX for Dummies Questions & Answers

Finding row number along with length of row

I have a fixed length file and I want to find out row number along with row length. I have a program that give me the line length if it satisfy the condition; but i would like to add row number as well? How do I do that? while IFS= read -r line; do if ; then echo ${line} echo... (8 Replies)
Discussion started by: princetd001
8 Replies

4. Shell Programming and Scripting

Shell Command to compare two xml lines while ignoring xml tags

I've got two different files and want to compare them. File 1 : HTML Code: <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record... (1 Reply)
Discussion started by: Shaishav Shah
1 Replies

5. Shell Programming and Scripting

The difference between end number in the early row and the start number in the next

Hi Power User, I'm trying to compute this kind of text file format: file1: jakarta 100 150 jakarta 170 210 beijing 220 250 beijing 260 280 beijing 290 320 new_york 330 350 new_york 370 420 tokyo 430 470 tokyo 480 ... (2 Replies)
Discussion started by: anjas
2 Replies

6. Shell Programming and Scripting

How to arrange xml tags in single row using shell script?

I want to put one xml record in one row and so on... sample two records are here. <?xml version="1.0"?> <Object> <Header> <XCOMVers>V1.0</XCOMVers> <REPORT>XXXXX</REPORT> <CODE>002</CODE> </Header> <IssueCard> <Record> <L>CAR SYSTEM -SSSSS -</L> ... (3 Replies)
Discussion started by: sene_geet
3 Replies

7. Shell Programming and Scripting

How to arrange xml tags in single row using shell script?

I want to put one xml record in one row and so on... sample two records are here. <?xml version="1.0"?> <Object> <Header> <XCOMVers>V1.0</XCOMVers> <REPORT>XXXXX</REPORT> <CODE>002</CODE> </Header> <IssueCard> <Record> <L>CAR SYSTEM -SSSSS -</L> ... (1 Reply)
Discussion started by: sene_geet
1 Replies

8. Shell Programming and Scripting

Replacing number between xml tags with ksh shell script

Hallo, im basically a complete noob on shell scripting and im trying to replace or rather add 1 to a number between xml tags. The xml basically has a tag somewhere that looks like this: <tag>12345678901234</tag> Now i want to replace the number between the tags. And i want the file to... (6 Replies)
Discussion started by: Demoric
6 Replies

9. Shell Programming and Scripting

how to add the number of row and count number of rows

Hi experts a have a very large file and I need to add two columns: the first one numbering the incidence of records and the another with the total count The input file: 21 2341 A 21 2341 A 21 2341 A 21 2341 C 21 2341 C 21 2341 C 21 2341 C 21 4567 A 21 4567 A 21 4567 C ... (6 Replies)
Discussion started by: juelillo
6 Replies

10. UNIX for Dummies Questions & Answers

Extract a specific number from an XML file based on the start and end tags

Hello People, I have the following contents in an XML file ........... ........... .......... ........... <Details = "Sample Details"> <Name>Bob</Name> <Age>34</Age> <Address>CA</Address> <ContactNumber>1234</ContactNumber> </Details> ........... ............. .............. (4 Replies)
Discussion started by: sushant172
4 Replies
Login or Register to Ask a Question