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

  • Home
  • SEARCH
  • 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 8816333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:35:52+00:00 2026-06-14T04:35:52+00:00

I am convert xml to xml file, I try to convert text as for

  • 0

I am convert xml to xml file, I try to convert text as for source. I am currently using xml::Twig and I need output without any change in xml.

I Tried:

xml:

<book>
<book-meta>
<book-id pub-id-type="doi">98568</book-id>
<copyright-statement>Copyright &#x00A9; 1999 Relati</copyright-statement>
<imprint-text type="PublisherInfo">This edition published in the Taylor &#x0026; 2002.</imprint-text>
</book-meta>
</book>

Script:

use strict;
use XML::Twig;
use XML::Xpath;
open(my $output , '>', "Output.xml") || die "can't open the Output $!\n";
my $xml_twig_content = XML::Twig->new(
twig_handlers => {
keep_atts_order => 1,
keep_encoding => 1,
},
pretty_print => 'indented',
);
$xml_twig_content->parsefile('sample.xml');
$xml_twig_content->print($output);

output:

<book>
<book-meta>
<book-id pub-id-type="doi">98568</book-id>
<copyright-statement>Copyright © 1999 Relati</copyright-statement>
<imprint-text type="PublisherInfo">This edition published in the Taylor &amp; 2002.</imprint-text>
</book-meta>
</book>

I need output:

<book>
<book-meta>
<book-id pub-id-type="doi">98568</book-id>
<copyright-statement>Copyright &#x00A9; 1999 Relati</copyright-statement>
<imprint-text type="PublisherInfo">This edition published in the Taylor &#x0026; 2002.</imprint-text>
</book-meta>
</book>

How can i need as source without any changes.

  • 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-14T04:35:53+00:00Added an answer on June 14, 2026 at 4:35 am

    There is a problem in your new statement: keep_encoding and keep_atts_order parameters are declared as twig_handlers. I don’t think that’s what you want, since the only thing this does is to die as soon as an element named keep_atts_order or keep_encoding is found in the XML.

    I think this is more like what you had in mind:

    my $xml_twig_content = XML::Twig->new( keep_atts_order => 1,
                                           keep_encoding => 1,
                                           pretty_print => 'indented',
                                         );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any PHP script to convert XML file to DTD. I tried a
I am in a need of programatically convert an Word-XML file into a RTF
How would you read an XML file using sax and convert it to a
i parsed my xml file successfully using sax parser.my doubt is how to convert
What is the easiest way to convert xml to html? I have xml file
I use a xsl tranform to convert a xml file to html in dotNet.
I have to write a Perl script to convert an XML file into a
I have an XML file and I have to convert it into a property
I am given a task to convert a huge table to custom XML file.
How to unzip a file from a folder, and then convert the XML document

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.