xml - bash script for replace text from two file in one -


i have 2 file xml; en.xml , it.xml

in default file language en.xml have structure

<string key="city not set">     <tr lang="en"> city not set </tr> 

in file it.xml have:

<string key="citt&agrave; non &egrave; impostato">     <tr lang="it">  </tr> 

in way can extract data it.xml , put in en.xml ?

from en.xml need string key

<string key="city not set"> 

in second file it.xml need change:

<string key="citt&agrave; non &egrave; impostato"> 

in :

<tr lang="it"> citt&agrave; non &egrave; impostato </tr> 

my goal obtain final result:

<string key="city not set">     <tr lang="it"> citt&agrave; non &egrave; impostato </tr> 

i hope clear.

i use parse xml:

get_data () { local tag=$1 local xml=$2  # find tag in xml, convert tabs spaces, remove leading spaces, remove tag. grep $tag $xml | \     tr '\011' '\040' | \     sed -e 's/^[ ]*//' \         -e 's/^<.*>\([^<].*\)<.*>$/\1/' } get_data \<tag_name\> filename.xml | tee output.txt cat output.txt 

and add bunch of if else commands relating input, prompts , stuff, , you've got functionable xml parser.

i use curl command parse xml feeds newspapers, , personal favourite rssmaker.

also, here's the source.

have fun!


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -