Skip to content

Instantly share code, notes, and snippets.

@ology
Created January 8, 2026 05:35
Show Gist options
  • Select an option

  • Save ology/23cb192b6c464c338388b955fc56b0e1 to your computer and use it in GitHub Desktop.

Select an option

Save ology/23cb192b6c464c338388b955fc56b0e1 to your computer and use it in GitHub Desktop.
mojo::dom::css
[
[
'tag', 'p', { id => 'a' }, [
'tag', 'div', {}, [ 'root', $_->[0][3] ], $_->[0], [
'tag', 'p', { id => 'b' }, $_->[0][3],
[ 'text', 123, $_->[0][3][5] ],
],
], [ 'text', 'Test', $_->[0] ],
], $_->[0][3][5],
]
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper::Compact qw(ddc);
use Mojo::DOM ();
use Mojo::DOM::CSS ();
my $dom = Mojo::DOM->new('<div><p id="a">Test</p><p id="b">123</p></div>');
my $css = Mojo::DOM::CSS->new(tree => $dom->tree);
my $elements = $css->select('p');
print ddc $elements;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment