The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
reading from stdin in a shell script mmesford Shell Programming and Scripting 4 07-04-2009 03:28 AM
file reading through shell script Dip Shell Programming and Scripting 4 10-21-2008 11:10 PM
reading XML datas via Shell Script freepal Shell Programming and Scripting 1 02-08-2008 11:52 AM
reading command output from shell script sri b Shell Programming and Scripting 4 11-16-2006 12:52 AM
Reading a table in a shell script luiscarvalheiro Shell Programming and Scripting 13 08-10-2006 07:16 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-26-2009
swetha123 swetha123 is offline
Registered User
  
 

Join Date: May 2009
Posts: 4
Smile reading xml attributes with shell script

Hi,

Iam new to shell scripting.I have below urgent requirement

I want to read attributes (transaction,documentmode) in xml tag with shell scripting and create a filename with these attribues

Xml :
<PURCHASE_10 partner="food" version="1.50" timestamp="2009-03-10T09:56:55" transaction="PURCHASEORDER" document_mode="abc">
</PURCHASE_10>

output : PURCHASEORDER_abc.xml

Ur help is appreciated

Thanks.
  #2 (permalink)  
Old 05-26-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
Hi ,

Code:
touch `sed -n 's/.*transaction="\(.*\)" document_mode="\(.*\)">/\1_\2.txt/p' Input_file.txt`

Don't post like ".I have below urgent requirement".
  #3 (permalink)  
Old 05-26-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,092

Code:
while(<DATA>){
	if(/.*transaction="([^"]*)".*document_mode="([^"]*)".*/){
		print "$1_$2.xml\n";
	}
}
__DATA__
<PURCHASE_10 partner="food" version="1.50" timestamp="2009-03-10T09:56:55" transaction="PURCHASEORDER" document_mode="abc"> 
</PURCHASE_10>

  #4 (permalink)  
Old 05-27-2009
swetha123 swetha123 is offline
Registered User
  
 

Join Date: May 2009
Posts: 4
Thanks a lot panyam.Its working as expected.

-----Post Update-----

Hi

How to capture the xml tag attribute value into a variable in shell script.

Thanks,
Sumi

-----Post Update-----

Hi

How to capture the xml tag attribute value into a variable in shell script.

Thanks,
Sumi

-----Post Update-----

Hi,

How to capture the xml tag attribute value into variable in shell script?

Thanks,
Sumi
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0