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 324237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:06:19+00:00 2026-05-12T09:06:19+00:00

I have a XML file of the format: <outer1> <inner1> <name>Stonecold</name> <profession>warrior</profession> <org>wwf</org> </inner1>

  • 0

I have a XML file of the format:

<outer1>
    <inner1>
        <name>Stonecold</name>
        <profession>warrior</profession>
        <org>wwf</org>
    </inner1>
    <inner1>
        <name>Shanebond</name>
        <profession>Bowler</profession>
        <org>newzealand</org>
    </inner1>
    <inner1>
        <name>brain schemidit</name>
        <profession>Chairman</profession>
        <org>Google</org>
    </inner1>
</outer1>

I want to change the value of Shanebond to Shane Bond.

I was using XML::Simple, but the result was a hash.

I want the same format as the input file. E.g: the output file should be as follows:

<outer1>
    <inner1>
        <name>Stonecold</name>
        <profession>warrior</profession>
        <org>wwf</org>
    </inner1>
    <inner1>
        <name>Shane Bond</name>
        <profession>Bowler</profession>
        <org>newzealand</org>
    </inner1>
    <inner1>
        <name>brain schemidit</name>
        <profession>Chairman</profession>
        <org>Google</org>
    </inner1>
</outer1>

Please advice how to do this.

Thanks in advance.

I want the output file to be saved in the same directory and if possible with the same name. is it possible?

  • 1 1 Answer
  • 1 View
  • 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-05-12T09:06:20+00:00Added an answer on May 12, 2026 at 9:06 am

    XML::Simple has options that allow you to specify how input will be transformed into a Perl data structure and how that structure will be output:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use XML::Simple;
    
    my $xml_file = 'b.xml';
    
    my $xml = XMLin(
        $xml_file,
        KeepRoot => 1,
        ForceArray => 1,
    );
    
    $xml->{outer1}->[0]->{inner1}->[1]->{name} = 'Shane Bond';
    
    XMLout(
        $xml,
        KeepRoot => 1,
        NoAttr => 1,
        OutputFile => $xml_file,
    );
    

    XML::Simple does get a little hairy if you do anything interesting because its purpose is not to be a general purpose XML library but to provide a simple way to deal with configuration files written in XML.

    CPAN has a plethora of XML related modules. Unless this was a one-off issue you had to deal with, it would be worth looking into some of the more capable and better suited modules.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file in a string in this format: <item> <name>xxx</name> <id>yyy</id>
I have an XML file in the following format: <doc> <id name=X> <type name=A>
So I have an XML file in the format: <projectlist> <project> <name>test</name> <type>deploy</type> <environment>dev</environment>
I have an XML File with the following format: <containers> <container> <item> item name
I have an XML file format that contains a structure of questions: <question id=q101>
I have an XML based file format that I'm using to store and load
I have a XML file with the following data format: <net NetName=abc attr1=123 attr2=234
I have an xml file in the following format: <food> <desert> cake <desert> </food>
I have an XSLT stylesheet that transforms an XML file to JSON format and
I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>

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.