Processing XML with Perl | Michel Rodriguez |
XML::Simple | Example: loading a configuration file |
Introduction to XML::Simple
Description
XML::Simple - Trivial API for reading and writing XML (esp config files)
XML::Simple loads an XML file in memory, in a convenient structure, that can be accessed and updated, then output back.
A number of options allow users to specify how the structure should be built. It can also be cached.
Notes: You should read the documentation for the forcearray option. Also note that name, key and id attributes have a special role in XML::Simple (see the keyattr option).
Why use XML::Simple?
- XML configuration files
- small table
- simple XML processing
- you don't care much about XML but find it convenient as a standard file format, to replace csv or a home-brewed format
Why NOT use XML::Simple?
- your XML data is too complex for XML::Simple to deal with:
- it includes mixed content (<elt>th<is>_</is>_ mixed content</elt>)
- you need to deal with character encodings
- your documents are too big to fit in memory - you want to use a standard-based module (XML::DOM for example)
XML::Simple | Example: loading a configuration file |