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 an HTML::Microformats::Format::XOXO::DD object. so many D's, we're thriving πŸ’€
  • $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. exactly that energy.

πŸ¦‹ HTML::Microformats::Format::XOXO::UL

represents an HTML UL element.

  • $ul->as_array β€” returns an array of values, where each is an HTML::Microformats::Format::XOXO::LI object.

🌈 HTML::Microformats::Format::XOXO::OL

represents an HTML OL element.

  • $ol->as_array β€” returns an array of values, where each is an HTML::Microformats::Format::XOXO::LI object.

πŸ“ 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 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). 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::Format
  • HTML::Microformats

πŸ’– AUTHOR πŸ’–

Toby Inkster <tobyink@cpan.org>. legend behaviour.


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