Sponsored Content
Full Discussion: XML data replacement
Top Forums Shell Programming and Scripting XML data replacement Post 302886964 by ratheeshjulk on Tuesday 4th of February 2014 04:20:50 PM
Old 02-04-2014
XML data replacement

I have below lines in a file
Code:
 <SubRecord>
    <Property Name="Name">QQQQQQQQ</Property>
    <Property Name="Prompt">YYYYYYYYYY</Property>
    <Property Name="Default">$ddd</Property>
    <Property Name="HelpTxt">blahblah</Property>
    <Property Name="ParamType">4</Property>
    <Property Name="ParamLength">0</Property>
    <Property Name="ParamScale">0</Property>
 </SubRecord>
<SubRecord>
  <Property Name="Name">$ABCD</Property>
  <Property Name="Prompt">ABCD</Property>
  <Property Name="Default">$ddd</Property>
  <Property Name="ParamType">0</Property>
  <Property Name="ParamLength">0</Property>
  <Property Name="ParamScale">0</Property>
</SubRecord>
 <SubRecord>
    <Property Name="Name">$XYZZ</Property>
    <Property Name="Prompt">XYZZ</Property>
    <Property Name="Default">$ddd</Property>
    <Property Name="ParamType">0</Property>
    <Property Name="ParamLength">0</Property>
    <Property Name="ParamScale">0</Property>
 </SubRecord>

in this file the piece in red should be replacd with below data
Code:
<SubRecord>
  <Property Name="Name">$XXXXXX</Property>
  <Property Name="Prompt">XXXXXX</Property>
  <Property Name="Default">sasasasasa</Property>
  <Property Name="ParamType">1</Property>
  <Property Name="ParamLength">0</Property>
  <Property Name="ParamScale">0</Property>
</SubRecord>


I am trying to bring the required tag alone into one single line and then use sed to replace the data
Code:
<SubRecord>
  <Property Name="Name">$ABCD</Property>
  <Property Name="Prompt">ABCD</Property>
  <Property Name="Default">$ddd</Property>
  <Property Name="ParamType">0</Property>
  <Property Name="ParamLength">0</Property>
  <Property Name="ParamScale">0</Property>
</SubRecord>

Code:
but not sure how to remove the newline characters inside a particular tag alone
something like  <SubRecord> .*ABCD.*ABCD.*</SubRecord>


Last edited by ratheeshjulk; 02-04-2014 at 05:21 PM.. Reason: Corrcted typo
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed xml file multiple line replacement

I have a file called config.xml, it's a simple xml file, and I need use sed/awk to erase some lines. <machine xsi:type="unix-machineType"> <name>server1</name> <node-manager> <name>server1</name> <listen-address>server1</listen-address> </node-manager> ... (3 Replies)
Discussion started by: cbo0485
3 Replies

2. Shell Programming and Scripting

XML tag replacement from different XML file

We have 2 XML file 1. ORIGINAL.xml file and 2. ATTRIBUTE.xml files, In the ORIGINAL.xml we need some modification as <resourceCode>431048</resourceCode>under <item type="Manufactured"> tag - we need to grab the 431048 value from tag and pass it to database table in unix shell script to find the... (0 Replies)
Discussion started by: balrajg
0 Replies

3. Shell Programming and Scripting

Data between XML Tags

<?xml version="1.0" encoding="iso-8859-1" ?> <TABLE> <TEST> <ID> 123 </ID> <name> abc </name> </TEST> <TEST> <ID> 123 </ID> <name> abc2 </name> </TEST> </TABLE> <TABLE> <TEST> <ID> 456 </ID> <name> def </name> </TEST> <TEST> ... (8 Replies)
Discussion started by: eskay
8 Replies

4. Shell Programming and Scripting

Scripting question, replacement in xml file

Hi Anybody can help me to make a script that replace string "Su saldo es" with "Your balance" in XML block if it start with Text Id=98 and Text Id= 12 only sample of part of file below <Text Id="98"> <Language id="1">Su saldo es $mainAccountBalance1Tiene ademas $dedicatedAccount1Balance1... (13 Replies)
Discussion started by: Ashu_099
13 Replies

5. Shell Programming and Scripting

XML id replacement with shell

Hi.. I have a problem with replacing of id-0f5435080b with some name daily, problem here is whenever I generate xml file it generates unique id for instance say for example today id-0f5435080b and tomorrow it may be id-0f68643508so basically I just want to replace this id with some name say... (5 Replies)
Discussion started by: nex_asp
5 Replies

6. HP-UX

XML tag name content replacement

Hi, Need to replace an XML tag name contents, please provide any suggestions. Scenario is : <abc_def>Value_some_content</abc_def> Expected output : <abc:def>Value_some_content</abc:def> We have many tag with different names & contents in a file or a string. Please help on the... (3 Replies)
Discussion started by: periyasamycse
3 Replies

7. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

8. Shell Programming and Scripting

Pulling data from xml

Hi there, Please could anyone help with this. I have an xml file that contains repeating values eg <Rule name> AAAAA <Action> BBBBB </Action> <Data> CCCCC </Data> <Type> DDDDD </Type> </Rule name> <Rule name> A1A1A1A1 <Action> B1B1B1B1 </Action> <Data> C1C1C1C </Data> <Type>... (4 Replies)
Discussion started by: ssideel
4 Replies

9. Programming

Resample time series data with replacement any way to do this in awk or just bash script

I have some time series data that I need to resample or downsample at some specific time intervals. The firs column is time in decimal hours. I am tryiong to resample this data every 3 minutse. So I need a data value ever 0.05. Here is the example data and as you can see, there time slot for 0.1500... (3 Replies)
Discussion started by: malandisa
3 Replies
All times are GMT -4. The time now is 11:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy