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

 About This Book

 Perl on Linux Systems

 ActivePerl on Windows Systems

 Data Types: Values and Variables

 Expressions, Operations and Simple Statements

 User Defined Subroutines

 Perl Built-in Debugger

 Name Spaces and Perl Module Files

 Symbolic (or Soft) References

 Hard References - Addresses of Memory Objects

 Objects (or References) and Classes (or Packages)

 Typeglob and Importing Identifiers from Other Packages

 String Built-in Functions and Performance

 File Handles and Data Input/Output

 Open Files in Binary Mode

 Open Directories and Read File Names

 File System Functions and Operations

 Converting Perl Script to Executable Binary

 Using DBM Database Files

 Using MySQL Database Server

 Socket Communication Over the Internet

XML::Simple Module - XML Parser and Generator

 XMLin() and XMLout() Methods

XML Parsing Options

 "forcearray" - Forcing Element Contents as Arrays

 "suppressempty" - Parsing Empty Elements

 "keyattr" - Namings Attributes as Keys

 XmlSimpleHash.pl - XML Hash Example

 XML Communication Model

 SOAP::Lite - SOAP Server-Client Communication Module

 Perl Programs as IIS Server CGI Scripts

 CGI (Common Gateway Interface)

 XML-RPC - Remote Procedure Call with XML and HTTP

 RPC::XML - Perl Implementation of XML-RPC

 Integrating Perl with Apache Web Server

 CGI.pm Module for Building Web Pages

 LWP::UserAgent and Web Site Testing


 PDF Printing Version