LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2008, 03:27 PM   #1
mcandy_123
LQ Newbie
 
Registered: Jan 2008
Posts: 4

Rep: Reputation: 0
Question how to find and read out parms in an xml file


hello !
I have for example following xml file content: <blabla>..<blabla/><blabla>..<blabla/><parm1>10</parm1><parm2>20<parm2/><blabla>..<blabla/><blabla>..<blabla/>
know I would like using grep or find or awk catch the parm 2 (20) by finding the value of parm 1 (10) first and displaying (print) parm 2 secondly.

Thanks in advance
br,
mcandy
 
Old 01-14-2008, 05:20 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927
Hi,

And welcome to LQ!

I'm not sure what the requirement is; is the name of the tag relevant at all,
or are you just looking for the first piece of VALUE after a value of 10?

[edit]
If my trivial assumption above was correct this simple sed below would do:

Code:
echo "<blabla>..<blabla/><blabla>..<blabla/><parm1>10</parm1><parm2>20<parm2/><blabla>..<blabla/><blabla>..<blabla/>"| sed -r 's/.+10<.+>([0-9]+).+/\1/g'
20
[/edit]


Cheers,
Tink

Last edited by Tinkster; 01-14-2008 at 05:23 PM. Reason: edit
 
Old 01-15-2008, 08:17 AM   #3
mcandy_123
LQ Newbie
 
Registered: Jan 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Question

Quote:
Originally Posted by Tinkster View Post
Hi,

And welcome to LQ!

I'm not sure what the requirement is; is the name of the tag relevant at all,
or are you just looking for the first piece of VALUE after a value of 10?

[edit]
If my trivial assumption above was correct this simple sed below would do:

Code:
echo "<blabla>..<blabla/><blabla>..<blabla/><parm1>10</parm1><parm2>20<parm2/><blabla>..<blabla/><blabla>..<blabla/>"| sed -r 's/.+10<.+>([0-9]+).+/\1/g'
20
[/edit]


Cheers,
Tink
Hi, Tink !
First of all, thanks for the reply !
my string looks like following:
long part befor in this string...<dscpService>0</dscpService><Enable>1</Enable>...long part afterwards
So, I should find first the tag <dscpService>0</dscpService> , which is uniq in this xml file and direct afterwards comes the Enable Flag which could be 0=off or 1=on. So I need to read the Enable flag or to define it in a parm.

hope thats a better description,
br,
mcandy
 
  


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
how do i read *.xml file on server Raakh Linux - Newbie 5 05-31-2007 07:09 AM
XML doesn't find XSL-file ronald-be Linux - Software 5 03-29-2006 12:24 PM
RSS XML File to be read and generate HTML page redhatrosh General 10 02-15-2006 02:16 AM
create, read and write a table in xml file using C alix123 Programming 1 12-02-2004 12:18 PM
How can i read an write to a HTML or xml file using C alix123 Programming 1 11-24-2004 05:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:17 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