Chapter 5 — Storing and Sharing Information 75
You can see the resulting XML generated from this file in Listing 5-10.
Listing 5-10: An XML File Generated from Fixed-Width File Data
1385674
4897947
2349875
In Listing 5-10, all of the data is stored within a
tained within a
individual tags.
For a more flexible programmable interface for building XML files in Perl, you can use the
XML::Generatormodule. The module provides a very flexible method for creating XML
and even nested XML. You can see a sample of this in Listing 5-11.
Listing 5-11: Generating XML with XML::Generator
use XML::Generator;
my $gen = XML::Generator->new(‘escape’ => ‘always’,
‘pretty’ => 2);
my $restaurants = {‘One on Wharf’ => {longitude => -0.64,
latitude => 52.909444},
Continued