The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Mechanize::XML - adds an XML DOM accessor to WWW::Mechanize.

VERSION

This document describes WWW::Mechanize::XML version 0.02

SYNOPSIS

    use WWW::Mechanize::XML;
    use Test::More;
    my $mech = WWW::Mechanize::XML->new();
    
    ok($mech->get('http://flickr.com/service/?method=getPhotos'), 'got photo list');
    lives_ok {
        $dom = $mech->xml();
    } 'got xml dom object';
    $root = $dom->domumentElement();
    my @photos = $root->findnodes('/rsp/photos/photo');
    is(scalar @photos, 23, 'got 23 photos');

DESCRIPTION

This is a subclass of WWW::Mechanize that provides an XML DOM accessor which parses the contents of the response and returns it as a XML::LibXML::Document. The motivation for developing this module was to facilitate testing of XML APIs and XHTML web pages.

METHODS

new( %options )

Creates a new WWW::Mechanize::XML object with the specified options. This constructor method accepts all of the arguments accepted by WWW::Mechanize - see WWW::Mechanize for further details. Other optional arguments accepted by this method are xml_parser_options and xml_error_options:

xml_parser_options

This argument, if specified, must be a hashref of valid XML::LibXML::Parser options which will be used to instantiate the XML parser. If no parser options are specified defaults are used. Please see the documentation for XML::LibXML::Parser for option descriptions and default values. Valid parser options accepted are:

validation
recover
recover_silently
expand_entities
keep_blanks
pedantic_parser
line_numbers
load_ext_dtd
complete_attributes
expand_xinclude
clean_namespaces

xml_error_options

This argument, if specified, must be a hashref containing at least the trigger_xpath key. If there is a value for the given xpath expression it will cause the call to xml() to die with that value. If a trigger_value key is specified the call will only die if the value at trigger_xpath equals trigger_value. If a message_xpath key is specified the call to xml() will die with the value at that path.

xml( )

Returns a XML::LibXML::Document object created from the response content by calling the XML::LibXML::Parser parse_string() method. Any parsing errors will propogate up. If xml_error_options were specified for this instance the response document is check for errors accordingly - this method will die if errors are found in the document as specified by the options.

DEPENDENCIES

WWW::Mechanize XML::LibXML File::Temp

BUGS

Please report any bugs you find via the CPAN RT system.

COPYRIGHT

Copyright Fotango 2006. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Barry White <bwhite@fotango.com>