http://qs1969.pair.com?node_id=1065471


in reply to How can I add missing XML open tags

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>

Replies are listed 'Best First'.
Re^2: How can I add missing XML open tags
by TheVend (Novice) on Dec 04, 2013 at 21:35 UTC
    Can XML::Twig be used to create a simple tab delimited CSV file?