HTML::...::XOXO(3pm)
β¨ HTML::Microformats::Format::XOXO β the XOXO microformat β¨
okay bestie, gather round, because we're talking about HTML::Microformats::Format::XOXO (that's the 3pm page, the Perl one, not a weird HTML thing, iykyk) π
π SYNOPSIS π
like, here's the whole vibe, copy-paste ready:
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
see how get_link_title just hands you the name, and the Eye colour lookup gives you Blue, and the hair colours join up into Blonde-Brown? iconic behaviour honestly π
πΈ DESCRIPTION πΈ
HTML::Microformats::Format::XOXO inherits from HTML::Microformats::Format. the base class definition is where you go for the description of property getter/setter methods, constructors, etc. β it's the parent, it raised this module right π«Ά
now here's the plot twist that makes this module different from most of the modules in the HTML::Microformats suite: the data method does not hand you a plain hashref. nope. it returns an HTML::Microformats::Format::XOXO::UL, an HTML::Microformats::Format::XOXO::OL, or an HTML::Microformats::Format::XOXO::DL object instead. main character energy, honestly β¨
π HTML::Microformats::Format::XOXO::DL
represents an HTML DL element. yes, the definition-list one. we love her.
$dl->get_values($key)β treats a DL as a key-value structure and returns a list of values for a given key. each value is anHTML::Microformats::Format::XOXO::DDobject. so many D's, we're thriving π$dl->as_hashβ returns a hash of keys pointing to arrayrefs of values, where each value is anHTML::Microformats::Format::XOXO::DDobject.$dl->as_arrayβ logically what you thinkget_values("*")might do. exactly that energy.
π¦ HTML::Microformats::Format::XOXO::UL
represents an HTML UL element.
$ul->as_arrayβ returns an array of values, where each is anHTML::Microformats::Format::XOXO::LIobject.
π HTML::Microformats::Format::XOXO::OL
represents an HTML OL element.
$ol->as_arrayβ returns an array of values, where each is anHTML::Microformats::Format::XOXO::LIobject.
π HTML::Microformats::Format::XOXO::LI
represents an HTML LI element. this one has the whole toolbelt, bestie:
$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, so it's giving raw, no filter.$li->get_link_typeβ returns the value of the type attribute of the first link found within the item. also 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. yes, the rel attribute β that's what the page says, don't @ me, I'm just relaying it faithfully π$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 anHTML::Microformats::Format::XOXO::DLobject representing the first DL element within the LI.$li->get_childrenβ returns anHTML::Microformats::Format::XOXO::OLorHTML::Microformats::Format::XOXO::ULobject representing the first OL or UL element within the LI.$li->get_value($key)β a shortcut for$li->get_properties->get_values($key). lazy girl summer, but make it efficient π
π§ HTML::Microformats::Format::XOXO::DD
this has an identical interface to HTML::Microformats::Format::XOXO::LI. that's it, that's the whole section. twin behaviour, no notes π
β MICROFORMAT β
HTML::Microformats::Format::XOXO supports XOXO as described at <http://microformats.org/wiki/xoxo>. go read the spec, bestie, it's literally right there.
π₯ RDF OUTPUT π₯
real talk: XOXO does not map especially naturally to RDF. so this module does the sensible thing and returns the data as a JSON literal, using the property <http://open.vocab.org/terms/json>. no cap, that's the whole deal.
π BUGS π
Please report any bugs to <http://rt.cpan.org/>. do it, don't be shy, the maintainers wanna know π«Ά
π SEE ALSO π
HTML::Microformats::FormatHTML::Microformats
π AUTHOR π
Toby Inkster <tobyink@cpan.org>. legend behaviour.
π 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.
like β no promises, no guarantees, she comes as she is, periodt. π
and that's the whole page, bestie! this one's from perl v5.32.1, dated 2021-09-12, and it lives under the name HTML::...::XOXO(3pm). go forth and extract those lists, you're gonna slay πβ¨π¦
π¦ where this page comes from
- debian bookworm: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms