NAME

WWW::Sitemap::Simple - simple sitemap builder

SYNOPSIS

    use WWW::Sitemap::Simple;

    my $sm = WWW::Sitemap::Simple->new;

    # simple way
    $sm->add('http://example.com/');

    # with params
    $sm->add(
        'http://example.com/foo' => {
            lastmod    => '2005-01-01',
            changefreq => 'monthly',
            priority   => '0.8',
        },
    );

    # set params later
    my $key = $sm->add('http://example.com/foo/bar');
    $sm->add_params(
        $key => {
            lastmod    => '2005-01-01',
            changefreq => 'monthly',
            priority   => '0.8',
        },
    );

    $sm->write('sitemap/file/path');

DESCRIPTION

WWW::Sitemap::Simple is the builder of sitemap with less dependency modules.

The Sitemap protocol: http://www.sitemaps.org/protocol.html

METHODS

new(%options)

constractor. There are optional parameters below.

urlset // { xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9' }
indent // "\t"
fatal // TRUE

If you add URLs more than 50,000 or generated XML file size over 10MB, then it will croak error.

add($url[, $params])

add new url. return an id(md5 hex string).

add_params($id, $params)

add parameters to url by id

get_id($url)

get an id for calling add_params method.

write([$file|$fh|$IO_OBJ])

write sitemap. By default, put sitemap to STDOUT.

urlset($hash)

get or set the urlset attribute as hash.

    my $sm = WWW::Sitemap::Simple->new;
    $sm->urlset({
        'xmlns' => "http://www.sitemaps.org/schemas/sitemap/0.9",
        'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
        'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
    });

indent($string)

get or set indent strings

fatal($boolean)

get or set boolean value for croaking

url

get all url hash lists

count

get a count of url

CAVEAT

Your Sitemap must be UTF-8 encoded (you can generally do this when you save the file). As with all XML files, any data values (including URLs) must use entity escape codes for the characters.

see more detail: http://www.sitemaps.org/protocol.html#escaping

REPOSITORY

WWW::Sitemap::Simple is hosted on github: http://github.com/bayashi/WWW-Sitemap-Simple

Welcome your patches and issues :D

AUTHOR

Dai Okabayashi <bayashi@cpan.org>

SEE ALSO

WWW::Sitemap::XML

Web::Sitemap

Search::Sitemap

LICENSE

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