NAME
XML::Lite - A lightweight XML parser for simple files
SYNOPSIS
use XML::Lite; my $xml = new XML::Lite( xml => 'a_file.xml' );
DESCRIPTION
XML::Lite is a lightweight XML parser, with basic element traversing methods. It is entirely self-contained, pure Perl (i.e. not based on expat). It provides useful methods for reading most XML files, including traversing and finding elements, reading attributes and such. It is designed to take advantage of Perl-isms (Attribute lists are returned as hashes, rather than, say, lists of objects). It provides only methods for reading a file, currently.
METHODS
The following methods are available:
- my $xml = new XML::Lite( xml => $source[, ...] );
-
Creates a new XML::Lite object. The XML::Lite object acts as the document object for the $source that is sent to it to parse. This means that you create a new object for each document (or document sub-section). As the objects are lightweight this should not be a performance consideration.
The object constructor can take several named parameters. Parameter names may begin with a '-' (as in the example above) but are not required to. The following parameters are recognized.
xml The source XML to parse. This can be a filename, a scalar that contains the document (or document fragment), or an IO handle.
As a convenince, if only on parameter is given, it is assumed to be the source. So you can use this, if you wish:
my $xml = new XML::Lite( 'file.xml' );
- my $elm = $xml->root_element()
-
Returns a reference to an XML::Lite::Element object that represents the root element of the document.
Returns
undef
on errors. - @list = $xml->elements_by_name( $name )
-
Returns a list of all elements that match
$name
.@list
is a list of XML::Lite::Element objects If called in a scalar context, this will return the first element found that matches (it's more efficient to call in a scalar context than assign the results to a list of one scalar).If no matching elements are found then returns
undef
in scalar context or an empty list in array context.
BUGS
(None known)
VERSION
0.11
AUTHOR
Jeremy Wadsack for Wadsack-Allen Digital Group (dgsupport@wadsack-allen.com)
COPYRIGHT
Copyright 2001 Wadsack-Allen. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.