# XML::RPC::Enc::LibXML - Encode/decode XML-RPC using LibXML - perldoc - [phpMan]

## NAME
    [XML::RPC::Enc::LibXML](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AEnc%3A%3ALibXML/markdown) - Encode/decode XML-RPC using LibXML

## SYNOPSIS
        use [XML::RPC::Fast](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AFast/markdown);
        use [XML::RPC::Enc::LibXML](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AEnc%3A%3ALibXML/markdown);

        my $rpc = [XML::RPC::Fast](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AFast/markdown)->new(
            $uri,
            encoder => [XML::RPC::Enc::LibXML](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AEnc%3A%3ALibXML/markdown)->new(
                # internal_encoding currently not implemented, always want wide chars
                internal_encoding => undef,
                external_encoding => 'windows-1251',
            )
        );

        $rpc->registerType( base64 => sub {
            my $node = shift;
            return [MIME::Base64::decode](https://www.chedong.com/phpMan.php/perldoc/MIME%3A%3ABase64%3A%3Adecode/markdown)($node->textContent);
        });

        $rpc->registerType( 'dateTime.iso8601' => sub {
            my $node = shift;
            return [DateTime::Format::ISO8601](https://www.chedong.com/phpMan.php/perldoc/DateTime%3A%3AFormat%3A%3AISO8601/markdown)->parse_datetime($node->textContent);
        });

        $rpc->registerClass( DateTime => sub {
            return ( 'dateTime.iso8601' => $_[0]->strftime('%Y%m%dT%H%M%S.%3N%z') );
        });

        $rpc->registerClass( DateTime => sub {
            my $node = [XML::LibXML::Element](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ALibXML%3A%3AElement/markdown)->new('dateTime.iso8601');
            $node->appendText($_[0]->strftime('%Y%m%dT%H%M%S.%3N%z'));
            return $node;
        });

## DESCRIPTION
    Default encoder/decoder for [XML::RPC::Fast](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AFast/markdown)

    If [MIME::Base64](https://www.chedong.com/phpMan.php/perldoc/MIME%3A%3ABase64/markdown) is installed, decoder for "XML-RPC" type "base64" will be setup

    If [DateTime::Format::ISO8601](https://www.chedong.com/phpMan.php/perldoc/DateTime%3A%3AFormat%3A%3AISO8601/markdown) is installed, decoder for "XML-RPC" type "dateTime.iso8601" will be
    setup

    Also will be setup by default encoders for [Class::Date](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADate/markdown) and DateTime (will be encoded as
    "dateTime.iso8601")

    Ty avoid default decoders setup:

        BEGIN {
            $[XML::RPC::Enc::LibXML::TYPES](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AEnc%3A%3ALibXML%3A%3ATYPES/markdown){base64} = 0;
            $[XML::RPC::Enc::LibXML::TYPES](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AEnc%3A%3ALibXML%3A%3ATYPES/markdown){'dateTime.iso8601'} = 0;
        }
        use [XML::RPC::Enc::LibXML](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AEnc%3A%3ALibXML/markdown);

## IMPLEMENTED METHODS
  new
  request
  response
  fault
  decode
  registerType
  registerClass
## SEE ALSO
    *   [XML::RPC::Enc](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ARPC%3A%3AEnc/markdown)

        Base class (also contains documentation)

    Q: What is the legal syntax (and range) for integers? How to deal with leading zeros? Is a
    leading plus sign allowed? How to deal with whitespace?

    A: An integer is a 32-bit signed number. You can include a plus or minus at the beginning of a
    string of numeric characters. Leading zeros are collapsed. Whitespace is not permitted. Just
    numeric characters preceded by a plus or minus.

    Q: What is the legal syntax (and range) for floating point values (doubles)? How is the exponent
    represented? How to deal with whitespace? Can infinity and "not a number" be represented?

    A: There is no representation for infinity or negative infinity or "not a number". At this time,
    only decimal point notation is allowed, a plus or a minus, followed by any number of numeric
    characters, followed by a period and any number of numeric characters. Whitespace is not
    allowed. The range of allowable values is implementation-dependent, is not specified.

                    # int
                    '+0' => 0
                    '-0' => 0
                    '+1234567' => 1234567
                    '0777' => 777
                    '0000000000000' => 0
                    '0000000000000000000000000000000000000000000000000' => 0
                    # not int
                    '999999999999999999999999999999999999';

COPYRIGHT & LICENSE
    Copyright (c) 2008-2009 Mons Anderson.

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

## AUTHOR
    Mons Anderson, "<<mons@cpan.org>>"

