XML::Beautify - Beautifies XML output from XML::Writer (soon to do any XML).
B<WARNING:> This is Alpha Software. The interface is still subject to change. Oh, and keep backups, Doh!!! B<WARNING:> This does not do well with already indented and formatted XML. I am still working on that. I am currently just reprinting the original string with E<additional whitespace>. I need to fix this by actually rewriting the XML from the element level on down using something like XML::Writer but adding in the whitespace. See E<recursive...>, Doh! use XML::Beautify qw(:const); # imports three constants (YES,NO,FULL) $obj_ref = XML::Beautify->new(); $cleanXML = $obj_ref->beautify(\$XMLstr); B<NB:> This uses Log::AndError for error handling and logging functions. This is imported as an @ISA and so anything you can do there you can do here.
Beautifies (converts to tree format) XML output from XML::Writer (soon to do any XML) to facilitate debugging XML or XML::Writer output.
Brown::Feeds::Entity::beutify()
$obj_ref->beautify(\$XML);
Parses the output of
($ok, $error) where $ok is 1 on success. $error is a diagnostic error message.
XML::Beautify::indent_str()
$indent_str = $obj_ref->indent_str(); # To retrieve the current value or $obj_ref->indent_str("\t"); # To set a new value
Sets or gets the indent str.
($indent_str) if set.
XML::Beautify::rem_cr()
$indent_str = $obj_ref->rem_cr(); # To retrieve the current value or $obj_ref->rem_cr(1); # To set a new value
Sets or gets the option to clean CR from XML before re-formatting.
(true) if set.
XML::Beautify::rem_ws()
$indent_str = $obj_ref->rem_ws(); # To retrieve the current value or $obj_ref->rem_ws(1); # To set a new value
Sets or gets the option to clean whitespace (Outside of char and cData) from XML before re-formatting. NB: This will remove blank whitespace from char sections if that is all that the char data contains.
XML::Beautify::orig_indent()
$indent_str = $obj_ref->orig_indent(); # To retrieve the current value or $obj_ref->orig_indent("\t"); # To set a new value
Sets or gets the original value for the indent incrementer. NB: Beware of setting this.
Deal with already formatted or mis-formatted XML.
Along those lines... Seriously consider reformatting each element in the XML from the data variable returned with the callback function instead of trying to miraculously use the original string.
Take an array ref, FH, etc; in addition to the scalar ref as an arg to beautify().
beautify()
Better documentation.
Replace static variables. (process started in ver 0.03)
See if the current state tracking can be replaced with context(), current_element(), in_element() functions from expat. (Related to above about statics)
context()
current_element()
in_element()
Thomas Bolioli <Thomas_Bolioli@alumni.adelphi.edu>
Copyright (c) 2001 Thomas Bolioli. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Log::AndError
Log::AndError::Constants
XML::Parser::Expat
1 POD Error
The following errors were encountered while parsing the POD:
=over without closing =back
To install XML::Beautify, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Beautify
CPAN shell
perl -MCPAN -e shell install XML::Beautify
For more information on module installation, please visit the detailed CPAN module installation guide.