NAME
Tk::XMLViewer - Tk widget to display XML
SYNOPSIS
use Tk::XMLViewer;
$xmlviewer = $top->XMLViewer->pack;
$xmlviewer->insertXML(-file => "test.xml");
$xmlviewer->insertXML(-text => "<?xml?><a><bla /><foo>bar</foo></a>");
DESCRIPTION
Tk::XMLViewer is an widget inherited from Tk::Text which displays XML in a hierarchical tree. You can use the plus and minus buttons to hide/show parts of the tree.
METHODS
- insertXML
-
Insert XML into the XMLViewer widget. Use the -file argument to insert a file and -text to insert an XML string.
- DumpXML
-
Dump the contents of an Tk::Text widget into an XML string, which can be used as input for the XMLViewer widget. Use the static variant for Tk::Text widgets and the method for XMLViewer widgets.
$xml_string1 = Tk::XMLViewer::DumpXML($text_widget); $xml_string2 = $xmlviewer->DumpXML;
- SetIndent
-
Set indent with for XML tags
$xmlviewer->SetIndent(width);
- XMLMenu
-
Insert XML Menu into Text widget menu.
$xmlviewer->XMLMenu;
- SourceType
-
Returns type of source used for last insertXML (-file or -text)
- SourceContent
-
Returns filename (source type -file) or XML text (source type -text) used for last insertXML.
- GetInfo
-
Returns hash of standard XML decl and DOCTYPE elements:
my %xmlheader = $xmlviewer->GetInfo;
Elements for XMLdecl: Version Encoding Standalone Elements for DOCTYPE: Name Sysid Pubid Internal
BUGS
Perl/Tk does not support Unicode, yet. For perl 5.6.0 and newer, unicode characters are translated to ISO-8859-1 chars, if possible. For older perls, there is no conversion (unless Unicode::String is installed), so unicode characters will show as binary values.
DumpXML will not work with nested text tags.
There should be only one insertXML operation at one time (these is probably only an issue with threaded operations, which do not work in Perl/Tk anyway).
Viewing of large XML files is slow.
head1 TODO
- show to depth n: close everything from depth n+1
- create menu item "close selected region"
- DTD validation (is this possible with XML::Parser?)
AUTHOR
Slaven Rezic, <eserte@cs.tu-berlin.de>
Some additions by Jerry Geiger <jgeiger@rios.de>.
SEE ALSO
XML::Parser(3), Tk::Text(3).