Or you could use XML::Twig ;--)
The important method here is insert. Here is the POD for it:
insert ($gi1, $optional_atts1, $gi2, $optional_atts2,...)
For each gi in the list inserts an element $gi as the only child of the element. The element gets the optional attributes in $optional_atts. All children of the element are set as children of the new element. The upper level element is returned.
put $p in a table with a visible border, a single tr and a single td and return the table element:$p->insert( table => { border=> 1}, 'tr', 'td')
<p><table border="1"><tr><td>original content of p</td></tr></table> +</p>
And the code that does what you want:
#!/usr/bin/perl -w use strict; use XML::Twig; my $t= XML::Twig->new( twig_handlers => { _all_ => sub { $_->insert( s +ort values %{$_->atts}); $_->del_atts; }, }, ) ->parse( \*DATA) ->print; __DATA__ <open1 type="head1"> This is test. <em type="italic">emp</em> this <i>emp</i> is <em type= +"bold">emp</em> test. </open1>
In reply to Re: XML to XML
by mirod
in thread XML to XML
by jdinesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |