Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Read xml file

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-08-2005
ram2s2001 ram2s2001 is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 5 April 2006, 1:27 AM EDT
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Read xml file

Iam new to shell script.
How to read xmlfile using shellscript(without awk),and Store record by record in file .

My xml file:

<root>

<header>
<HeaderData1>header1</HeaderData1>
<HeaderData2>header2</HeaderData2>
</header>

<detailsRecord>
<DetailRecord1>detail1</DetailRecord1>
<DetailRecord2>detail2</DetailRecord2>
<detailsRecord>

<detailsRecord>
<DetailRecord1>detail3</DetailRecord1>
<DetailRecord2>detail4</DetailRecord2>

<detailsRecord>

<trailer>
<trailer>trailer1</trailer>
</trailer>

</root>







Thanks Lot.
Sponsored Links
    #2  
Old Unix and Linux 12-09-2005
Neo's Unix or Linux Image
Neo Neo is online now Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 30 May 2015, 12:12 AM EDT
Location: Asia pacific region
Posts: 13,156
Thanks: 649
Thanked 972 Times in 444 Posts
You can uses PERL or PHP...... works great.

Neo
Sponsored Links
    #3  
Old Unix and Linux 12-11-2005
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 12 March 2015, 5:33 AM EDT
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
What are records for you ? All the data that appear between the tags ?

If it is, this sed will do it.


Code:
sed -n -e 's_.*>\(.*\)<.*_\1_p' input.xml > record.txt

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end victor.s UNIX for Dummies Questions & Answers 3 11-09-2011 09:41 AM
Read file and for each line replace two variables, add strings and save output in another file Andy_ARG Shell Programming and Scripting 5 03-03-2011 12:25 AM
bash: read file line by line (lines have '\0') - not full line has read??? alex_5161 Shell Programming and Scripting 6 04-14-2010 04:58 AM
Cannot read a file with read(fd, buffer, buffersize) function naranja18she Programming 3 06-12-2009 01:39 PM
Post Shell programming: Question about source a file and read data from the file ccwq Shell Programming and Scripting 3 08-04-2007 10:28 PM



All times are GMT -4. The time now is 12:25 AM.