note dist has been murderized
[catagits/DOM-Tiny.git] / README.pod
index 19c666e..fc667fe 100644 (file)
@@ -77,8 +77,8 @@ names are lowercased and selectors need to be lowercase as well.
   my $dom = DOM::Tiny->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.
+If an XML declaration is found, the parser will automatically switch into XML
+mode and everything becomes case-sensitive.
 
   # XML semantics
   my $dom = DOM::Tiny->new('<?xml version="1.0"?><P ID="greeting">Hi!</P>');
@@ -394,7 +394,7 @@ objects. All selectors listed in L</"SELECTORS"> are supported.
 
   $dom = $dom->append('<p>I ♥ DOM::Tiny!</p>');
 
-Append HTML/XML fragment to this node.
+Append HTML/XML fragment to this node (for all node types other than C<root>).
 
   # "<div><h1>Test</h1><h2>123</h2></div>"
   $dom->parse('<div><h1>Test</h1></div>')
@@ -427,8 +427,8 @@ node's content.
   my $result = $dom->at('div ~ p');
 
 Find first descendant element of this element matching the CSS selector and
-return it as a L<DOM::Tiny> object or return C<undef> if none could be found.
-All selectors listed in L</"SELECTORS"> are supported.
+return it as a L<DOM::Tiny> object, or C<undef> if none could be found. All
+selectors listed in L</"SELECTORS"> are supported.
 
   # Find first element with "svg" namespace definition
   my $namespace = $dom->at('[xmlns\:svg]')->{'xmlns:svg'};
@@ -584,7 +584,7 @@ L</"SELECTORS"> are supported.
 
   my $namespace = $dom->namespace;
 
-Find this element's namespace or return C<undef> if none could be found.
+Find this element's namespace, or return C<undef> if none could be found.
 
   # Find namespace for an element with namespace prefix
   my $namespace = $dom->at('svg > svg\:circle')->namespace;
@@ -596,8 +596,8 @@ Find this element's namespace or return C<undef> if none could be found.
 
   my $sibling = $dom->next;
 
-Return L<DOM::Tiny> object for next sibling element or C<undef> if there are no
-more siblings.
+Return L<DOM::Tiny> object for next sibling element, or C<undef> if there are
+no more siblings.
 
   # "<h2>123</h2>"
   $dom->parse('<div><h1>Test</h1><h2>123</h2></div>')->at('h1')->next;
@@ -606,7 +606,7 @@ more siblings.
 
   my $sibling = $dom->next_node;
 
-Return L<DOM::Tiny> object for next sibling node or C<undef> if there are no
+Return L<DOM::Tiny> object for next sibling node, or C<undef> if there are no
 more siblings.
 
   # "456"
@@ -621,8 +621,11 @@ more siblings.
 
   my $parent = $dom->parent;
 
-Return L<DOM::Tiny> object for parent of this node or C<undef> if this node has
-no parent.
+Return L<DOM::Tiny> object for parent of this node, or C<undef> if this node
+has no parent.
+
+  # "<b><i>Test</i></b>"
+  $dom->parse('<p><b><i>Test</i></b></p>')->at('i')->parent;
 
 =head2 parse
 
@@ -631,7 +634,7 @@ no parent.
 Parse HTML/XML fragment.
 
   # Parse XML
-  my $dom = DOM::Tiny->new->xml(1)->parse($xml);
+  my $dom = DOM::Tiny->new->xml(1)->parse('<foo>I ♥ DOM::Tiny!</foo>');
 
 =head2 preceding
 
@@ -659,7 +662,7 @@ before this node as L<DOM::Tiny> objects.
 
   $dom = $dom->prepend('<p>I ♥ DOM::Tiny!</p>');
 
-Prepend HTML/XML fragment to this node.
+Prepend HTML/XML fragment to this node (for all node types other than C<root>).
 
   # "<div><h1>Test</h1><h2>123</h2></div>"
   $dom->parse('<div><h2>123</h2></div>')
@@ -691,7 +694,7 @@ node's content.
 
   my $sibling = $dom->previous;
 
-Return L<DOM::Tiny> object for previous sibling element or C<undef> if there
+Return L<DOM::Tiny> object for previous sibling element, or C<undef> if there
 are no more siblings.
 
   # "<h1>Test</h1>"
@@ -701,7 +704,7 @@ are no more siblings.
 
   my $sibling = $dom->previous_node;
 
-Return L<DOM::Tiny> object for previous sibling node or C<undef> if there are
+Return L<DOM::Tiny> object for previous sibling node, or C<undef> if there are
 no more siblings.
 
   # "123"
@@ -837,13 +840,13 @@ C<root>, C<tag> or C<text>.
   my $value = $dom->val;
 
 Extract value from form element (such as C<button>, C<input>, C<option>,
-C<select> and C<textarea>) or return C<undef> if this element has no value. In
+C<select> and C<textarea>), or return C<undef> if this element has no value. In
 the case of C<select> with C<multiple> attribute, find C<option> elements with
-C<selected> attribute and return an array reference with all values or C<undef>
-if none could be found.
+C<selected> attribute and return an array reference with all values, or
+C<undef> if none could be found.
 
   # "a"
-  $dom->parse('<input name="test" value="a">')->at('input')->val;
+  $dom->parse('<input name=test value=a>')->at('input')->val;
 
   # "b"
   $dom->parse('<textarea>b</textarea>')->at('textarea')->val;
@@ -859,12 +862,15 @@ if none could be found.
   $dom->parse('<select multiple><option selected>e</option></select>')
     ->at('select')->val->[0];
 
+  # "on"
+  $dom->parse('<input name=test type=checkbox>')->at('input')->val;
+
 =head2 wrap
 
   $dom = $dom->wrap('<div></div>');
 
-Wrap HTML/XML fragment around this node, placing it as the last child of the
-first innermost element.
+Wrap HTML/XML fragment around this node (for all node types other than C<root>),
+placing it as the last child of the first innermost element.
 
   # "<p>123<b>Test</b></p>"
   $dom->parse('<b>Test</b>')->at('b')->wrap('<p>123</p>')->root;
@@ -882,8 +888,8 @@ first innermost element.
 
   $dom = $dom->wrap_content('<div></div>');
 
-Wrap HTML/XML fragment around this node's content, placing it as the last
-children of the first innermost element.
+Wrap HTML/XML fragment around this node's content (for C<root> and C<tag>
+nodes), placing it as the last children of the first innermost element.
 
   # "<p><b>123Test</b></p>"
   $dom->parse('<p>Test<p>')->at('p')->wrap_content('<b>123</b>')->root;
@@ -897,7 +903,7 @@ children of the first innermost element.
   $dom     = $dom->xml($bool);
 
 Disable HTML semantics in parser and activate case-sensitivity, defaults to
-auto detection based on processing instructions.
+auto detection based on XML declarations.
 
 =head1 COLLECTION METHODS
 
@@ -1118,7 +1124,7 @@ Report any issues on the public bugtracker.
 
 Dan Book <dbook@cpan.org>
 
-Code and tests adapted from L<Mojo::DOM> by the L<Mojolicious> team.
+Code and tests adapted from L<Mojo::DOM>, a lightweight DOM parser by the L<Mojolicious> team.
 
 =head1 CONTRIBUTORS
 
@@ -1130,7 +1136,9 @@ Code and tests adapted from L<Mojo::DOM> by the L<Mojolicious> team.
 
 =head1 COPYRIGHT AND LICENSE
 
-This software is Copyright (c) 2015 by Dan Book.
+Copyright (c) 2008-2015 Sebastian Riedel.
+
+Copyright (c) 2015 L</"AUTHOR"> and L</"CONTRIBUTORS"> for adaptation to standalone format.
 
 This is free software, licensed under: