http://www.perlmonks.org?node_id=928513


in reply to Re: How can I replace a line (tag) in an XML file?
in thread How can I replace a line (tag) in an XML file?

The problem with XML::Simple (well, one of) when using it to edit a file is that it tends to change the XML in ways that do not make a difference when the file is read by XML::Simple, but will cause all other tools to fail to read it.

In this particular case all those content-only tags will become attributes of the parent tag. XML::Simple will not mind, other tools most probably will.

Not speaking about the fact that your code would not work ... there is no load() or save() in XML::Simple and the data structure would look different than what you seem to think.

Jenda
Enoch was right!
Enjoy the last years of Rome.

  • Comment on Re^2: How can I replace a line (tag) in an XML file?

Replies are listed 'Best First'.
Re^3: How can I replace a line (tag) in an XML file?
by AlexTape (Monk) on Sep 29, 2011 at 10:52 UTC
    i´m sorry - sunken in my own projects i should probably post full storys ;-)
    sub load{return%{XML::Simple->new(ForceContent=>1)->XMLin($_[0])};}#lo +ads xml sub save{XMLout($_[1],OutputFile=>$_[0]);1;}#saves hash to xml
    but your still mostly right.. for me it works fine..
    $perlig =~ s/pec/cep/g if 'errors expected';