Skip to content

Commit

Permalink
more verbose examples for case-sensitivity in Mojo::DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 18, 2015
1 parent 4c9f7e8 commit 6998ff3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Mojo/DOM.pm
Expand Up @@ -432,22 +432,26 @@ L</"attr"> and L</"namespace"> only apply to elements.
L<Mojo::DOM> defaults to HTML semantics, that means all tags and attribute
names are lowercased and selectors need to be lowercase as well.
# HTML semantics
my $dom = Mojo::DOM->new('<P ID="greeting">Hi!</P>');
say $dom->at('p[id]')->text;
If XML processing instructions are found, the parser will automatically switch
into XML mode and everything becomes case-sensitive.
# XML semantics
my $dom = Mojo::DOM->new('<?xml version="1.0"?><P ID="greeting">Hi!</P>');
say $dom->at('P[ID]')->text;
XML detection can also be disabled with the L</"xml"> method.
# Force XML semantics
$dom->xml(1);
my $dom = Mojo::DOM->new->xml(1)->parse('<P ID="greeting">Hi!</P>');
say $dom->at('P[ID]')->text;
# Force HTML semantics
$dom->xml(0);
my $dom = Mojo::DOM->new->xml(0)->parse('<P ID="greeting">Hi!</P>');
say $dom->at('p[id]')->text;
=head1 METHODS
Expand Down

0 comments on commit 6998ff3

Please sign in to comment.