Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How can I add missing XML open tags

by toolic (Bishop)
on Dec 03, 2013 at 18:40 UTC ( #1065471=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1065471]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2022-11-30 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?