Sponsored Content
Top Forums Shell Programming and Scripting Replace text inside XML file based on condition Post 302576539 by kmsekhar on Friday 25th of November 2011 07:01:22 AM
Old 11-25-2011
Lightbulb Replace text in XML file based on Previous Line

Hi All,

I want to change the name as SEQ_13
ie., <Property Name="Name">SEQ_13</Property>
when the Stage Type is PxSequentialFile
ie., <Property Name="StageType">PxSequentialFile</Property> Smilie

Input.XML
Code:
 
<Main>
      <Record Identifier="V0S13" Type="CustomStage" Readonly="0">
         <Property Name="Name">Sequential_File_13</Property>
         <Property Name="NextID">2</Property>
         <Property Name="InputPins">V0S13P1</Property>
         <Property Name="StageType">PxSequentialFile</Property>
         <Property Name="AllowColumnMapping">0</Property>
         <Property Name="NextRecordID">0</Property>
      </Record>
        ......
         ......
 
</Main>


Output.XML
Code:
<Main>
      <Record Identifier="V0S13" Type="CustomStage" Readonly="0">
         <Property Name="Name">SEQ_13</Property>
         <Property Name="NextID">2</Property>
         <Property Name="InputPins">V0S13P1</Property>
         <Property Name="StageType">PxSequentialFile</Property>
         <Property Name="AllowColumnMapping">0</Property>
         <Property Name="NextRecordID">0</Property>
      </Record>
        ......
         ......
 
</Main>

Thanks in advance

Last edited by kmsekhar; 11-25-2011 at 08:22 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to replace a text inside a file based on a xml key

<c-param> <param-name>Number</param-name> <param-value>22</param-value> <description>my house number</description> </c-param> <c-param> <param-name>Address</param-name> ... (4 Replies)
Discussion started by: reldb
4 Replies

2. Shell Programming and Scripting

pattern replace inside text file using sed

Hi, I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file. For Example: If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained. But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Discussion started by: meharo
4 Replies

3. Shell Programming and Scripting

Remove lines from XML based on condition

Hi, I need to remove some lines from an XML file is the value within a tag is empty. Imagine this scenario, <acd><acdID>2</acdID><logon></logon></acd> <acd><acdID></acdID><logon></logon></acd> <acd><acdID></acdID><logon></logon></acd> <acd><acdID></acdID><logon></logon></acd> I... (3 Replies)
Discussion started by: giles.cardew
3 Replies

4. Shell Programming and Scripting

extract xml tag based on condition

Hi All, I have a large xml file of invoices. The file looks like below: <INVOICES> <INVOICE> <NAME>Customer A</NAME> <INVOICE_NO>1234</INVOICE_NO> </INVOICE> <INVOICE> <NAME>Customer A</NAME> <INVOICE_NO>2345</INVOICE_NO> </INVOICE> <INVOICE> <NAME>Customer A</NAME>... (9 Replies)
Discussion started by: angshuman
9 Replies

5. Shell Programming and Scripting

Help with File processing - Adding predefined text to particular record based on condition

I am generating a output: Name Count_1 Count_2 abc 12 12 def 15 14 ghi 16 16 jkl 18 18 mno 7 5 I am sending the output in html email, I want to add the code: <font color="red"> NAME COLUMN record </font> for the Name... (8 Replies)
Discussion started by: karumudi7
8 Replies

6. Shell Programming and Scripting

Check the value in xml based on condition

Hi, I have a log file having n number of xml's like the one below. <uOStatus xmlns:env="http://abc.org/def/ghi/"... (3 Replies)
Discussion started by: Neethu
3 Replies

7. Shell Programming and Scripting

Copy and paste text inside a xml file

I have a really big XML file. I need copy the value of one tag inside another one tag. I try to publish one example. <channel update="i" site="merge-xmltv" site_id="" xmltv_id="Rai 1">Rai 1</channel> <channel update="i" site="merge-xmltv" site_id="" xmltv_id="Rai 1 +2HD">Rai 1... (6 Replies)
Discussion started by: Tapiocapioca
6 Replies

8. Shell Programming and Scripting

Help with tag value extraction from xml file based on a matching condition

Hi , I have a situation where I need to search an xml file for the presence of a tag <FollowOnFrom> and also , presence of partial part of the following tag <ContractRequest _LoadId and if these 2 exist ,then extract the value from the following tag <_LocalId> which is "CW2094139". There... (2 Replies)
Discussion started by: paul1234
2 Replies

9. UNIX for Beginners Questions & Answers

Find replace text in xml file on the fly

Dear Unix guru, I have a .XML file which is being used to load data to oracle. This file comes on unix box and one of the tag in xml is oracle key word. I want to find that tag and replace with new tag on the fly For example I will get one of the tag in xml is as below <from>Test Test... (12 Replies)
Discussion started by: guddu_12
12 Replies

10. UNIX for Beginners Questions & Answers

Manipulate condition to send mail based on output text in file

Hi All, I have a working script as below. echo "Files loaded with $(cat /var/tmp/script.X1.out)" | mail -s "Files loaded with return code" mailid This script takes the output from script.X1.out file and appends the text "Files loaded with return code" and sends the email. Now what I want... (5 Replies)
Discussion started by: midhun3108
5 Replies
POM_XPATH_REPLACE(7)						Java Packages Tools					      POM_XPATH_REPLACE(7)

NAME
pom_xpath_replace - replace XML node from POM file with given XML code SYNOPSIS
%pom_xpath_replace XPath XML-code [POM-location] DESCRIPTION
This macro patches specified POM file removing all XML nodes described by the XPath expression and injecting given XML code in their place. XPath is an expression describing a set of XML nodes to be removed from the POM file. It must be a properly formated XPath 1.0 expression, as described in http://www.w3.org/TR/xpath/. POM location can be either a full path to the POM file, or a path to the directory containing pom.xml. If POM location is not given then pom.xml from current working directory is used. BUGS
POM files use a specific namespace - http://maven.apache.org/POM/4.0.0. Currently this namespace needs to be explicitly specified in all XPath POM macros by prefixing all node names with pom:. AUTHOR
Written by Mikolaj Izdebski. REPORTING BUGS
Bugs should be reported through Red Hat Bugzilla at http://bugzilla.redhat.com/. SEE ALSO
pom_add_dep(7), pom_add_parent(7), pom_add_plugin(7), pom_disable_module(7), pom_remove_dep(7), pom_remove_parent(7), pom_remove_plugin(7), pom_set_parent(7), pom_xpath_inject(7), pom_xpath_remove(7), pom_xpath_set(7). JAVAPACKAGES
06/10/2014 POM_XPATH_REPLACE(7)
All times are GMT -4. The time now is 03:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy