Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8173083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:00:27+00:00 2026-06-06T22:00:27+00:00

i have an xml <Data> <employee> <name>emp1</name> <id>1</id> </employee> </Data> lets say i have

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:00:30+00:00Added an answer on June 6, 2026 at 10:00 pm

    You can use xmlstarlet to update your template.xml(which is ill-formed)

    $ cat template.xml 
    <employee>
     <name>##name##</name> 
     <id>##empid##</id>
    </employee>
    
    $ xmlstarlet ed -u //name -v emp2 -u //id -v 2 template.xml 
    <?xml version="1.0"?>
    <employee>
      <name>emp2</name>
      <id>2</id>
    </employee>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XML data which contains a long attribute value. The value does not
I have the following XML: <data name=zzz_AbsenceReportDR time=2012-06-19 13:36:40Z xmlns=> <row conf=88945498 date=6/19/2012 employee_identifier=mickeymouse
I have a single xml document (data.xml), which I display as HTML using an
I have a xml doc as below. <data> <employee> <moretag> may or may not
Have a xml data like <Items><Item><name>test1</name></Item><Item><name>test2</name></Item></Items> Looks like jaxb cannot unmashall this when defining
I have a xml data as below: <list> <com.domain.Products> <cla__id> <cname>class1</cname> <id>1</id> </cla__id> <name>pname1</name>
I have some XML data which includes URIs. I want to list the URIs
I have some xml data contained in three files (Database.xml, Participants.xml, and ConditionTokens.xml). I
I have an xml data file and I want to populate a listview in
I have grabbed some XML data using this piece of jQuery: $.ajax({ type: POST,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.