Removal of a tag in the xml which occurs mutiple times


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removal of a tag in the xml which occurs mutiple times
# 1  
Old 03-24-2011
Removal of a tag in the xml which occurs mutiple times

Hi,

The tag can occur multiple times.

I want to remove entire <SeqNum>..</SeqNum> from each line, regardless the values with in this tag. for each line value inside these tags could be different. So please suggest how to do this.

Note: Each profile information is in one line.

Output i am getting is as below:
----------
Code:
<Body><Profile><Id>123</Id><ContactMethods><Contacts><SeqNum>1</SeqNum><Phone>12345</Phone></Contacts><Contacts><SeqNum>4</SeqNum><Phone>89045</Phone></Contacts></ContactMethods><Address><SeqNum>8</SeqNum><addr>xyz</addr></Address></profile></Body> 
<Body><Profile><Id>ABNV123</Id><ContactMethods><Contacts><SeqNum>3</SeqNum><Phone>345789</Phone></Contacts><Contacts><SeqNum>5</SeqNum><Phone>45689045</Phone></Contacts></ContactMethods><Address><SeqNum>6</SeqNum><addr>ABCF</addr></Address></profile></Body>


Expected Output is:
--------------------
Code:
<Body><Profile><Id>123</Id><ContactMethods><Contacts><Phone>12345</Phone></Contacts><Contacts><Phone>89045</Phone></Contacts></ContactMethods><Address><addr>xyz</addr></Address></profile></Body> 
<Body><Profile><Id>ABNV123</Id><ContactMethods><Contacts><Phone>345789</Phone></Contacts><Contacts><Phone>45689045</Phone></Contacts></ContactMethods><Address><addr>ABCF</addr></Address></profile></Body>


Thanks,

Last edited by Franklin52; 03-24-2011 at 08:15 AM.. Reason: Please use code tags
# 2  
Old 03-24-2011
Code:
sed 's:<SeqNum>[^<]*</SeqNum>::g' infile

# 3  
Old 03-24-2011
Perl
Code:
perl -pe 's#<SeqNum>(.+?)</SeqNum>##g' inputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving XML tag/contents after specific XML tag within same file

Hi Forum. I have an XML file with the following requirement to move the <AdditionalAccountHolders> tag and its content right after the <accountHolderName> tag within the same file but I'm not sure how to accomplish this through a Unix script. Any feedback will be greatly appreciated. ... (19 Replies)
Discussion started by: pchang
19 Replies

2. Shell Programming and Scripting

sed command to replace one value which occurs multiple times

Hi, My Input File : "MN.1.2.1.2.14.1.1" := "MN_13_TM_4" ( 000000110110100100110001111110110110101110101001100111110100011010110111001 ) "MOS.1.2.1.2.13.6.2" := "MOS_13_TM_4" ( 000000110110100100110001111110110110101110101001100111110100011010110111001 ) Like above template,I have... (4 Replies)
Discussion started by: Preeti Chandra
4 Replies

3. Shell Programming and Scripting

Counting number of times content in columns occurs in other files

I need to figure out how many times a location (columns 1 and 2) is present within a group of files. I figured using a combination of 'while read' and 'grep' I could count the number of instances but its not working for me. cat file.txt | while read line do grep $line *08-new.txt | wc -l... (6 Replies)
Discussion started by: ncwxpanther
6 Replies

4. Shell Programming and Scripting

To search for a particular tag in xml and collate all similar tag values and display them count

I want to basically do the below thing. Suppose there is a tag called object1. I want to display an output for all similar tag values under heading of Object 1 and the count of the xmls. Please help File: <xml><object1>house</object1><object2>child</object2>... (9 Replies)
Discussion started by: srkmish
9 Replies

5. Shell Programming and Scripting

XML Parse between to tag with upper tag

Hi Guys Here is my Input : <?xml version="1.0" encoding="UTF-8"?> <xn:MeContext id="01736"> <xn:VsDataContainer id="01736"> <xn:attributes> <xn:vsDataType>vsDataMeContext</xn:vsDataType> ... (12 Replies)
Discussion started by: pareshkp
12 Replies

6. Shell Programming and Scripting

How to retrieve the value from XML tag whose end tag is in next line

Hi All, Find the following code: <Universal>D38x82j1JJ </Universal> I want to retrieve the value of <Universal> tag as below: Please help me. (3 Replies)
Discussion started by: mjavalkar
3 Replies

7. UNIX for Dummies Questions & Answers

how to read how many times same result occurs?

Is there a way to read how many times each result occurs in a list, say the list.txt has the results: a c d a f c a d e and I need to know how many times each of them occurs such as : a=3 c=2 ..etc. (5 Replies)
Discussion started by: Iifa
5 Replies

8. Shell Programming and Scripting

Script to check for the newest file mutiple times a day and SCP it to another server.

Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server. Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the... (1 Reply)
Discussion started by: richasmi
1 Replies

9. Shell Programming and Scripting

Looking for a single line to count how many times one character occurs in a word...

I've been looking on the internet, and haven't found anything simple enough to use in my code. All I want to do is count how many times "-" occurs in a string of characters (as a package name). It seems it should be very simple, and shouldn't require more than one line to accomplish. And this is... (2 Replies)
Discussion started by: Shingoshi
2 Replies

10. Shell Programming and Scripting

TO find the word which occurs maximum number of times

Hi Folks !!!!!!!!!!!!!!!!!!! My Requirement is............. i have a input file: 501,501.chan 502,502.anand 503,503.biji 504,504.raja 505,505.chan 506,506.anand 507,507.chan and my o/p should be chan->3 i.e. the word which occurs maximum number of times in a file should be... (5 Replies)
Discussion started by: aajan
5 Replies
Login or Register to Ask a Question