Using XML::Mini for the first time today. Read in an XML file, modified an attribute and wrote the file back out again. XML::Mini has stripped off the last character of any element names which dont hold data. Such as <element/>. Anyone else had this issue? Works OK when elements with no data in look like  <element> </element> Also works OK when the the empty element looks like
<element />
Guess I have the answer.
#!/usr/local/bin/perl -w use strict; use XML::Mini; use XML::Mini::Document; use Data::Dumper; my $xmlDoc = XML::Mini::Document->new(); #my $in_file_name="W:\\switch_upload\\xml\\batchjob.xml"; #my $out_file_name="W:\\switch_upload\\xml\\batchjob_out.xml"; my $root_dir="/export/home/set/scripts/perl/switch_upload/xml/"; my $in_file_name=$root_dir."batchjob.xml"; my $out_file_name=$root_dir."batchjob_out.xml"; #$xmlDoc->fromFile($in_file_name); $xmlDoc->parse($in_file_name); my $var = $xmlDoc->getElement("BATCH"); $var->attribute('name','JCI BATCH December 2003'); #print Dumper($xmlDoc); $xmlDoc->toFile($out_file_name);

janitored by ybiC: Retitle from "Mini::XML Stripping Last Character From Element Names" so title contains correct module name. Search-foo, yo. Also linked module name within post using PM [cpan://XML::Mini]


In reply to XML::Mini Stripping Last Character From Element Names by set_uk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.