=pod =head1 SYNOPSIS parse(\%parsedTree, \$parseThis, 'topTag', $comments); =head1 DESCRIPTION =over =item parsedTree - required reference to hash to store the parsed document within =item parseThis - required reference to scalar containg the document to parse =item topTag - optional tag to consider the root node, leaving this undefined is not recommended. =item comments - optional =over =item false will remove contents from =item true will not remove comments =item array reference is true, comments are stored here =back =back =head1 CAVEATS Not a conforming parser, it does not handle the following =over =item =item =item =item PI =back It's non-validating, without a DTD the following cannot be addressed =over =item entities =item namespace =back =cut sub parseXML{ my($hash, $xml, $tag, $comments) = @_; my($begin, $end, @comments); local $_; #Kill comments while( ($begin = index(${$xml}, '') for @comments; #Expose comments if requested do{ push(@$comments, $_->[1]) for @comments } if ref($comments) eq 'ARRAY'; } }