LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-06-2006, 06:50 PM   #1
Manuel Alvarado
LQ Newbie
 
Registered: Sep 2006
Posts: 1

Rep: Reputation: 0
String manipulation


Hello,

I'm looking for a linux command to extract specific strings from an xml documents. For example, the following string:
<name>John Doe</name>

I have tried "grep", but this produces the entire line of text which is too much to handle or to focus on. I will appreciate any possible help!

Thanks!

Manuel Alvarado
 
Old 09-06-2006, 06:53 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Have a look at sed and awk.
Perl, Python or Ruby would be suitable as well if you know them.

Your life would likely be much easier if you picked a scripting language and used one of the many XML libraries available...
 
Old 09-06-2006, 09:49 PM   #3
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.
Quote:
Originally Posted by Manuel Alvarado
I'm looking for a linux command to extract specific strings from an xml documents. For example, the following string:
<name>John Doe</name>

I have tried "grep", but this produces the entire line of text which is too much to handle or to focus on.
Many people find this of some use:
Code:
       -o, --only-matching
              Show only the part of a matching line that matches PATTERN.
-- excerpt from man grep
For more flexibility, you might, as bulliver noted, need to consider a scripting language ... cheers, makyo
 
  


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
string manipulation mannahazarika Programming 6 12-31-2005 11:02 AM
Filename string manipulation jango77 Linux - Newbie 2 03-27-2005 06:58 PM
bash + string manipulation dave bean Programming 7 02-16-2005 11:16 AM
String manipulation with a script. philipina Programming 4 03-16-2004 02:42 PM
String manipulation with a script? philipina General 1 03-15-2004 12:07 PM

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

All times are GMT -5. The time now is 09:38 AM.

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