in reply to XML::Simple $elt->noattr is there an equivalent using XML::Twig
First question : Why do I have element 'opt' not myconfig_data at the docroot level ?
You need to use the KeepRoot option I think.
More generally, using simplify in XML::Twig is a 1 way street: you can get a data structure from an element, but there is no going back. The method is designed to help people used to XML::Simple to be able to use techniques they are familiar with, when extracting data from XML. If you want to work with the twig and turn attributes into elements, then you will have to do it yourself:
#totally untested! sub att_to_children { my( $elt)= @_; foreach my $att ($elt->att_names) { $elt->insert_new_elt( last_child => $att, $elt->att); } $elt->del_atts; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::Simple $elt->noattr is there an equivalent using XML::Twig
by Anonymous Monk on Mar 01, 2006 at 11:23 UTC | |
by mirod (Canon) on Mar 01, 2006 at 13:59 UTC |