Perl Tutorials - Herong's Tutorial Examples - Version 5.32, by Dr. Herong Yang
XML Parsing Options
This section describes commonly used options supported by the XML::Simple module that controls how to handle root element and empty elements. 'forcearray => 1' option is needed if you want to text elements to parsed as arrays.
XML::Simple options can be specified in the new() method call:
$xs = new XML::Simple(option1 => value, option2 => value, ...);
Commonly used options are:
1. keeproot => 1: Applies to both XMLin() and XMLout() to keep the root tag.
2. searchpath => list: Applies to XMLin() to specifies the directories to search for input XML files.
3. forcearray => 1: Applies to XMLin() to force the contents of all elements to be an array.
4. suppressempty => 1 or '': Applies to XMLin() to skip empty elements or to represent them as '' strings. The default behavior is to represent empty elements as references of empty hashes. The default behavior makes it hard to access empty elements in the parsed hash.
5. keyattr => list: Applies to XMLin() and XMLout() to name attributes, or sub-elements as keys to be used to promote the parent element from array to hash. Remember that there is a default list: "name", "key", and "id".
Table of Contents