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
how to get data from xml files tags(from data tags) pvr_satya Shell Programming and Scripting 9 08-16-2008 10:19 AM
data base update mleplawy Shell Programming and Scripting 1 05-31-2008 08:35 AM
Update NIS+ data djunerup SUN Solaris 0 03-26-2008 11:37 AM
How to compare data in two flat files and update them? rajus19 Shell Programming and Scripting 3 11-08-2005 11:13 AM
Removing leading and trailing spaces of data between the tags in xml. jhmr7 UNIX for Dummies Questions & Answers 2 05-18-2005 11:27 AM

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 01-22-2009
harry_todd harry_todd is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 2
How to update data between xml tags

Is there a way to modify Non Null data between <host> and </host> tags to a new value ?- may be using sed/awk?
I tried this sed 's|.*<host>\(?*\)</host>.*|\<host>xxx</host>|' but it is updating the host which has null value - want opposite of this - Thanks in advance for you help!!

For Example:
<node>node1</node>
<host>178.23.43</host>
<node>node2</node>
<host></host>
<node>node3</node>
<host>usilsunny1</host>
<node>node4</node>
<host> </host>

should modify to

<node>node1</node>
<host>NewHostHame</host>
<node>node2</node>
<host></host>
<node>node3</node>
<host>NewHostHame</host>
<node>node4</node>
<host></host>
  #2 (permalink)  
Old 01-22-2009
rubin's Avatar
rubin rubin is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2007
Posts: 321

Code:
awk -F'<|>' '/<host>[^<>]+<\/host>/{sub($3,"NewHostHame")}1' file

  #3 (permalink)  
Old 01-23-2009
harry_todd harry_todd is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 2
Perfect - Thank you so much!!

Perfect - Thank you so much!!
Closed Thread

Bookmarks

Tags
tag, update

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 09:48 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