XML::Twig empty_tags => 'expand' looks like it does what you want. I shortened your XML and fixed the closing "orders tag":
use warnings;
use strict;
use XML::Twig;
my $xml = <<XML;
<orders>
<order>
<alt_number>2222</alt_number>
<state>processed</state>
<user_id>1234</user_id>
<dd_id>54321</dd_id>
<placed_at/>
<total_price>449.0</total_price>
<total_shipping_costs>90.0</total_shipping_costs>
<discount>0</discount>
<dd_status_code>HD</dd_status_code>
<dd_status_desc>ORDER IS ON HOLD UNTIL 11/01/13</dd_status_desc>
<promo_code/>
</order>
</orders>
XML
my $twig = XML::Twig->new(
pretty_print => 'indented',
empty_tags => 'expand',
);
$twig->parse($xml);
$twig->print;
__END__
Output:
<orders>
<order>
<alt_number>2222</alt_number>
<state>processed</state>
<user_id>1234</user_id>
<dd_id>54321</dd_id>
<placed_at></placed_at>
<total_price>449.0</total_price>
<total_shipping_costs>90.0</total_shipping_costs>
<discount>0</discount>
<dd_status_code>HD</dd_status_code>
<dd_status_desc>ORDER IS ON HOLD UNTIL 11/01/13</dd_status_desc>
<promo_code></promo_code>
</order>
</orders>
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|