LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2008, 09:33 AM   #1
mcandy_123
LQ Newbie
 
Registered: Jan 2008
Posts: 4

Rep: Reputation: 0
Question find an TAG in a file and specify a parm


Hello Cracks !
I have a sh-script, where I want to define a parm with an value fount in an xml file.
my file looks like :
............<VALUE_1>0</VALUE_1><VALUE_2>1</VALUE_2>.........

as the TAG "<VALUE_1>0</VALUE_1>" is in different releases on various positions in this file ,it is my KEY to search for. The TAG "<VALUE_2>1</VALUE>" comes alway behind the TAG "<VALUE_1>0</VALUE_1>" and is the one which i would like to print.
so my parm in the sh-script should look like:
a=`find "<VALUE_1>0</VALUE_1>" , print "<VALUE_2>1</VALUE_2>"`

I dont know what to use awk, find, sed etc.

any idea?
Thanks in advance
mcandy
 
Old 01-17-2008, 09:57 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
if your xml file is not too big and there's only 1 pair of value1 and value2,
Code:
tr "\n" " " < file.xml | sed 's/.*<VALUE_1>\(.*\)<\/VALUE_1>.*<VALUE_2>\(.*\)<\/VALUE_2>.*/value 1 is \1 => value 2 is \2 \n/'
otherwise, forget about this.
 
Old 01-17-2008, 01:00 PM   #3
mcandy_123
LQ Newbie
 
Registered: Jan 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Talking guys, you are increadble !!!!!!!

THANK YOU SO MUCH !



Quote:
Originally Posted by ghostdog74 View Post
if your xml file is not too big and there's only 1 pair of value1 and value2,
Code:
tr "\n" " " < file.xml | sed 's/.*<VALUE_1>\(.*\)<\/VALUE_1>.*<VALUE_2>\(.*\)<\/VALUE_2>.*/value 1 is \1 => value 2 is \2 \n/'
otherwise, forget about this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
doom2 iwad tag in file header lugoteehalt Linux - Software 2 07-23-2007 11:15 AM
saving id3 tag from mp3 file fstephens Linux - Newbie 3 04-07-2007 02:52 PM
ssh max connections parm DotHQ Linux - Software 1 08-31-2006 09:13 PM
spec file programming - Require tag rindjon Programming 2 03-29-2006 03:17 AM
Tag Editor for Audio File (Various Format) edwin11 Linux - Software 4 02-03-2006 12:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration