i have an xml
<Data>
<employee>
<name>emp1</name>
<id>1</id>
</employee>
</Data>
lets say i have template in which i change value and add in to previous xml
<employee>
<name>##name##</name>
<id>##empid##</id>
<employee>
i replace original value with ##name## and ##empid## and put in original xml
name=emp2
eid=2
so after that it sud be
<Data>
<employee>
<name>emp1</name>
<id>1</id>
</employee>
<employee>
<name>emp2</name>
<id>2</id>
</employee>
</Data>
i tried getting line no to insert tags
line=$(cat data.xml | grep -n '</Data>' | grep -o '^[0-9]*')
and
tried to put text in to original xml using
sed $line\ i\<text to be insert in original xml>
but it gives some error with xml content ,help will be appriciated ,as i am new to shell script
You can use
xmlstarletto update yourtemplate.xml(which is ill-formed)