I've seen variations of this same question asked but I have not been able to find an answer that fits my problem. Please direct me to another post if there already is a solution to this.
I'm trying to write a Unix script to dynamically iterate through a flat file and replace a value in an XML when a match is found.
For example:
Flat file contains multiple entries in the format of -
Pre-script XML contains multiple entries in the format of -
How do I replace <value> tags in the XML with the text after '~' when the <name> tag matches the part before '~'; Essentially, parsing the flat file based on the tildes. So after running the script I will have
Post-script XML:
Any suggestions are appreciated. I don't have code to share, I just need a starting point.
Moderator's Comments:
edit by bakunin: please use CODE-tags as you agreed to do when you accepted the forum rules. Thank you.
Not sure I understand. Text and samples seem somewhat contradictory. Does your flat file contain one or several replacement entries? Which one to use, then? Do you want to replace every occurrence in the XML file with the replacement values? If no, which to replace?
Hi, please help on this. I want extract values of xml file structure and print in determined way.
<ProjectName> --> only appears once
<StructList> --> is the top node
<Struct> node --> could be more than 1
NameID, STX, STY, PRX, PRY --> appears only 1 time within each <Struct> node... (10 Replies)
Good Afternoon Team -
I"m asking for assistance on a piece of code to populate two values in an XML file. I have it working perfectly using CScript for DOS, but I have a need to do that same process in a Linux environment.
Here is the XML I need to modify:
<?xml version="1.0"... (5 Replies)
Hi All,
Please find the code below where I want to add the variable value in between the XML tags. I am taking one string and my goal is to put them between the xml tags. Ex : in between <name> , <lname>
Kindly suggest a correction because while executing this script I am getting and... (8 Replies)
:wall: Hi,
I have an XML file with 5 tags. I need to pass values to the XML file from a shell script that will replace values in 2 of the tags. I cannot hardcode the tag values in XML and use replace command in script as the values are likely to change.
Please help !!!!!!!!!!! (2 Replies)
Search and Replace a string pattern with empty in an xml file in unix:
My xml file would be like this :
<Accounts><Name>Harish</Name><mobile>90844444444444445999 </mobile><TRIG>srcujim-1</TRIG></Accounts><Accounts><Name>Satish</Name><mobile>908999</mobile><TRIG>ettertrtt-1</TRIG></Accounts>
... (1 Reply)
Hi,
I am new to UNIX and shell scripting.
I have to create a shell script(ksh) which parses log4j.xml file for a given webservice name and change the corresponding value from INFO to DEBUG or vice-versa.
My log4j.xml looks like:-
<!-- Appender WEBSERVICENAME-->
<appender... (3 Replies)
Hello all,
I try to create a bash script but till now without any positiv results.
The script should replace different variables in a text file with the right xml values
Look at the following xml file:
file.xml
===================================
<?xml version="1.0"... (14 Replies)
Hallo all,
I try to create a bash script but till now without any positiv results.
The script should replace different variables in a text file with the right xml values
Look at the following xml file:
file.xml
===================================
<?xml version="1.0"... (1 Reply)
Hi All,
I am new to Unix I need a KSH script to get the values from XML file to write to a temp file.
Like the requirement is from the below TAG
<MAPPING DESCRIPTION ="Test Mapping" ISVALID ="YES" NAME ="m_test_xml" OBJECTVERSION ="1" VERSIONNUMBER ="1">
I need the MAPPING DESCRIPTION... (3 Replies)