hi,
The code's output doesn't include the xml declaration <?xml
version="1.0"?>, how to fix the issue in the program?

use XML::Simple;

my $cust_xml = XMLin('./customers.xml', forcearray=>1,KeepRoot=>1);

for my $customer (@{$cust_xml->{customer}}) {
 # Capitalize the contents of the 'first-name' and 'surname' elements
 # by running Perl's built-in uc( ) function on them
 foreach (qw(first-name surname)) {
   $customer->{$_}->[0] = uc($customer->{$_}->[0]);
 }
}

print XMLout($cust_xml, RootName=>'');
print "\n";

<?xml version="1.0"?>
<spam-document version="3.5" timestamp="2002-05-13 15:33:45">
<!-- Autogenerated by WarbleSoft Spam Version 3.5 -->
<customer>
 <first-name>Joe</first-name>
 <surname>Wrigley</surname>
 <address>
   <street>17 Beable Ave.</street>
   <city>Meatball</city>
   <state>MI</state>
   <zip>82649</zip>
 </address>
 <email>[EMAIL PROTECTED]</email>
 <age>42</age>
</customer>
<customer>
 <first-name>Henrietta</first-name>
 <surname>Pussycat</surname>
  <address>
   <street>R.F.D. 2</street>
   <city>Flangerville</city>
   <state>NY</state>
   <zip>83642</zip>
  </address>
  <email>[EMAIL PROTECTED]</email>
  <age>37</age>
 </customer>
</spam-document>

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"[EMAIL PROTECTED]
")'

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to