The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX Desktop for Dummies Questions & Answers
.
google unix.com



UNIX Desktop for Dummies Questions & Answers Discuss UNIX and Linux user interfaces like GNOME, KDE, CDE, and Open Office here. All UNIX and Linux Newbies Welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
print the line immediately after a regexp; but regexp is a sentence ownins UNIX for Dummies Questions & Answers 3 11-16-2008 02:30 AM
Help with regexp agasamapetilon Shell Programming and Scripting 7 09-20-2008 04:30 PM
How to read element of line of file ahjiefreak High Level Programming 1 04-20-2008 02:21 PM
regexp with sed again!!! andy2000 Shell Programming and Scripting 2 05-03-2007 10:15 AM
regexp penfold UNIX for Advanced & Expert Users 1 06-28-2005 07:45 AM

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

Join Date: Dec 2006
Posts: 6
read XML xml element with REGEXP

Hi, I would need to read an xml element from an xml file to a local variable. Please could you help me with a shell script to get so? Considering that I have a file called file.xml like below:

<header>
<description>This is the description</description>
<content>This is the content</content>
</header>

What I'd like is to assign the value of "description" tag ("This is the description") to a local variable.

I guess this could be done by usig regular expressions...

Thanks in advance.
  #2 (permalink)  
Old 01-21-2009
oscarmon oscarmon is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 6
I should have looked deeper into the Forums. I have found a good solution in How To get the data from a tag in XML File

Thks.
  #3 (permalink)  
Old 01-21-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,912
Hre is one way of doing it
Code:
var=$(sed -n 's/\(<description>\)\([[:print:]]*\)<\/[^>]*>/\2/p' infile
Sponsored Links
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 04:41 PM.


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