Replace xml values


 
Thread Tools Search this Thread
Top Forums Web Development Replace xml values
# 1  
Old 11-29-2008
Replace xml values

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" encoding="UTF-8"?>
<Daten>
<export_date>2008-07-15 16:29:01</export_date>
<language>english</language>
===================================

temp.txt

===================================
All dates were exported at <export_date>
The text was translated in <language>
===================================

script.sh

===================================
#!/bin/bash

IFS=$'\n'

for i in `cat file.xml | sed 's/>/ /g' | awk '{print $1}' | sed 's/</ /g' | sed 's/ //g'`
do


for j in `grep "$i" temp.txt | sed 's/.*<//g'| sed 's/>.*//g' `
do
#echo $j
for h in `cat temp.txt | sed -e "s/"$j"/$(cat file.xml | grep "$j" | sed 's/>/ /g' | sed 's/</ /g' | awk '{print $2}')/g" >> temp2 `
do
echo $h
done
done


done
==================================================


The aim should be

All dates were exported at 2008-07-15 16:29:01
The text was translated in english.

Do you know how I could work on this?

thx
# 2  
Old 11-29-2008
No duplicate or cross-posting, read the rules.

Proceed here:

https://www.unix.com/shell-programmin...#post302262925

Thread closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Script to populate (2) values in .XML

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)
Discussion started by: SIMMS7400
5 Replies

2. Shell Programming and Scripting

AIX UNIX Script to Replace XML Values

Hi - 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... (4 Replies)
Discussion started by: ocbit
4 Replies

3. Shell Programming and Scripting

Parse XML For Values

Hi All, I want to parse XML to extract values of the tags to do further processing. The XML looks like <?xml version="1.0" encoding="ISO-8859-1"?> <allinput> <input A="2389906" B="install"> <C>111</C> <D>222</D> <E>333</E> <F></F> <G>444</G> <H></H> <I></I> <J></J> <K>C,D,E,G</K>... (6 Replies)
Discussion started by: rahulmittal87
6 Replies

4. Shell Programming and Scripting

Comparing delta values of one xml file in other xml file

Hi All, I have two xml files. One is having below input <NameValuePair> <name>Daemon</name> <value>tcp:7474</value> </NameValuePair> <NameValuePair> <name>Network</name> <value></value> </NameValuePair> ... (2 Replies)
Discussion started by: sharsour
2 Replies

5. Shell Programming and Scripting

Find out values between xml tag

Find out values between xml tag ....... ABC><name></ABC><xyz>test</xyz>..here some other tag... <ABC><NUMBER></ABC><xyz>12345</xyz>.... ....... I want to take between bewtween ABC><NUMBER></ABC><xyz> to </xyz> that is 12345 (3 Replies)
Discussion started by: Jairaj
3 Replies

6. Shell Programming and Scripting

Extract values from an XML File

Hi, I need to capture all the attributes with delete next to it. The source XML file is attached. The output should contain something like this below: Attributes = legacyExchangeDN Action = Delete Username = Hero Joker Loginid = joker09 OU =... (4 Replies)
Discussion started by: prvnrk
4 Replies

7. Shell Programming and Scripting

How to get values from xml tags?

Hi guys, Need ur help again. Source File is coming like this. sample two records are below: <?xml version="1.0"?> <Object> <Header> <XCOMVers>V1.0</XCOMVers> <REPORT>XXXXX</REPORT> <CODE>002</CODE> </Header> <IssueCard> <Record> <L>CAR SYSTEM -SSSSS ... (3 Replies)
Discussion started by: sene_geet
3 Replies

8. Shell Programming and Scripting

Parsing Values from XML

Hi all, Can anyone help me out in parsing values from the xml in shell script below.. <DropDB> <DBName>RMDatabase</DBName> <UName>root</UName> <PWord>test</PWord> </DropDB> I need the values RMDatabase , root and test alone ... :wall: Thanks in advance :) ... (2 Replies)
Discussion started by: selvarajvs
2 Replies

9. UNIX for Dummies Questions & Answers

Extracting values from an XML file

Hello People, I have an xml file from which I need to extract the values of the parameters using UNIX shell commands. Ex : Input is like : <Name>Roger</Name> or <Address>MI</Address> I need the output as just : Roger or MI with the tags removed. Please help. (1 Reply)
Discussion started by: sushant172
1 Replies

10. Shell Programming and Scripting

Replace xml values -- Shell --

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)
Discussion started by: research3
14 Replies
Login or Register to Ask a Question