Discipulus has asked for the wisdom of the Perl Monks concerning the following question:
..and a simple XML file:#!/bin/perl -w use strict; use XML::Twig; my $file = 'orders.xml' ; my $ext = '.'.time; my $twig = XML::Twig->new(pretty_print => 'indented'); #$twig->parsefile( $file) or die "could not parse!"; $twig->parsefile_inplace ( $file, $ext) ; $twig->print();
but when i run this the XML is printed to STDOUT (it is not selected the FH to the output file?) and i find myself with an empty orders.xml file and a correct sized orders.xml.1374219815 file.<?xml version="1.0"?> <Order> <Date>2003/07/04</Date> <CustomerId>123</CustomerId> <CustomerName>Acme Alpha</CustomerName> <Item> <ItemId> 987</ItemId> <ItemName>Coupler</ItemName> <Quantity>5</Quantity> </Item> <Item> <ItemId>654</ItemId> <ItemName>Connector</ItemName> <Quantity unit="12">3</Quantity> </Item> <Item> <ItemId>579</ItemId> <ItemName>Clasp</ItemName> <Quantity>1</Quantity> </Item> </Order>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Twig parsefile_inplace misunderstanding
by Corion (Patriarch) on Jul 19, 2013 at 08:25 UTC | |
|
Re: XML::Twig parsefile_inplace misunderstanding
by mirod (Canon) on Jul 19, 2013 at 09:26 UTC | |
by Discipulus (Canon) on Jul 19, 2013 at 09:51 UTC | |
by mirod (Canon) on Jul 19, 2013 at 10:08 UTC | |
|
Re: XML::Twig parsefile_inplace misunderstanding (xml_pp twig_handlers _all_ flush)
by Anonymous Monk on Jul 19, 2013 at 09:02 UTC | |
by Discipulus (Canon) on Jul 19, 2013 at 09:27 UTC | |
by Anonymous Monk on Jul 19, 2013 at 09:57 UTC |