NAME¶
HTML::Microformats::Format::XOXO - the XOXO microformat
SYNOPSIS¶
use HTML::Microformats::DocumentContext;
use HTML::Microformats::Format::XOXO;
my $context = HTML::Microformats::DocumentContext->new($dom, $uri);
my @objects = HTML::Microformats::Format::XOXO->extract_all(
$dom->documentElement, $context);
my $list = $objects[0];
# Let's assume this structure:
#
# <ol class="xoxo people">
# <li>
# <a href="http://tobyinkster.co.uk/">Toby Inkster</a>
# <dl>
# <dt>Eye colour</dt>
# <dd>Blue</dt>
# <dt>Hair colour</dt>
# <dd>Blonde</dt>
# <dd>Brown</dt>
# </dl>
# </li>
# </ol>
print $list->data->as_array->[0]->get_link_title;
# Toby Inkster
print $list->data->as_array->[0]->get_properties
->get_value('Eye colour')->[0];
# Blue
print join '-', $list->data->as_array->[0]
->get_value('Hair colour');
# Blonde-Brown
DESCRIPTION¶
HTML::Microformats::Format::XOXO inherits from HTML::Microformats::Format. See
the base class definition for a description of property getter/setter methods,
constructors, etc.
Unlike most of the modules in the HTML::Microformats suite, the "data"
method returns an HTML::Microformats::Format::XOXO::UL,
HTML::Microformats::Format::XOXO::OL or HTML::Microformats::Format::XOXO::DL
object, rather than a plain hashref.
Represents an HTML DL element.
- "$dl->get_values($key)"
- Treating a DL as a key-value structure, returns a list of values for a
given key. Each value is an HTML::Microformats::Format::XOXO::DD
object.
- "$dl->as_hash"
- Returns a hash of keys pointing to arrayrefs of values, where each value
is an HTML::Microformats::Format::XOXO::DD object.
- "$dl->as_array"
- Logically what you think get_values("*") might do.
Represents an HTML UL element.
- "$ul->as_array"
- Returns an array of values, where each is a
HTML::Microformats::Format::XOXO::LI object.
Represents an HTML OL element.
- "$ol->as_array"
- Returns an array of values, where each is a
HTML::Microformats::Format::XOXO::LI object.
Represents an HTML LI element.
- "$li->get_link_href"
- Returns the URL linked to by the first link found within the
item.
- "$li->get_link_rel"
- Returns the value of the rel attribute of the first link found within the
item. This is an unparsed string.
- "$li->get_link_type"
- Returns the value of the type attribute of the first link found within the
item. This is an unparsed string.
- "$li->get_link_title"
- Returns the value of the rel attribute of the first link found within the
item if present; the link text otherwise.
- "$li->get_text"
- Returns the value of the text in the LI element except for the
first DL element within the LI, and the first UL or OL element.
- "$li->get_html"
- Returns the HTML code in the LI element except for the first DL
element within the LI, and the first UL or OL element.
- "$li->get_properties"
- Returns an HTML::Microformats::Format::XOXO::DL object representing the
first DL element within the LI.
- "$li->get_children"
- Returns an HTML::Microformats::Format::XOXO::OL or
HTML::Microformats::Format::XOXO::UL object representing the first OL or
UL element within the LI.
- "$li->get_value($key)"
- A shortcut for
"$li->get_properties->get_values($key)".
This has an identical interface to HTML::Microformats::Format::XOXO::LI.
HTML::Microformats::Format::XOXO supports XOXO as described at
<
http://microformats.org/wiki/xoxo>.
RDF OUTPUT¶
XOXO does not map especially naturally to RDF, so this module returns the data
as a JSON literal using the property <
http://open.vocab.org/terms/json>.
BUGS¶
Please report any bugs to <
http://rt.cpan.org/>.
SEE ALSO¶
HTML::Microformats::Format, HTML::Microformats.
AUTHOR¶
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE¶
Copyright 2008-2012 Toby Inkster
This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
DISCLAIMER OF WARRANTIES¶
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.