Tk::XMLViewer - Tk widget to display XML |
Tk::XMLViewer - Tk widget to display XML
use Tk::XMLViewer; $xmlviewer = $top->XMLViewer->pack; $xmlviewer->insertXML(-file => "test.xml"); $xmlviewer->insertXML(-text => '<?xml version="1.0" encoding="ISO-8859-1" ?><a><bla /><foo>bar</foo></a>');
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.
Tk::XMLViewer
supports all option of Tk::Text
and additionally
the following:
The text tags xml_tag
, xml_attrkey
, xml_attrval
, and
xml_comment
are defined for the corresponding XML elements. If you
want to customize further you can configure the tags directly, for
example:
$xmlviewer->tagConfigure('xml_comment', -foreground => "white", -background => "red", -font => "Helvetica 6");
Tk::Text
widget into an XML string. This is
meant as a alternative to the Tk::Text::dump
method (in fact,
DumpXML
is implemented with the help of dump
).
The output of DumpXML
can be used as input for the XMLViewer
widget, which is useful in debugging Tk::Text
tags.
Use the static variant of DumpXML
for Tk::Text
widgets and the
method variant for XMLViewer
widgets.
$xml_string1 = Tk::XMLViewer::DumpXML($text_widget); $xmlviewer_widget->insertXML($xml_string1);
$xml_string2 = $xmlviewer->DumpXML;
$xmlviewer->SetIndent(width);
$xmlviewer->XMLMenu;
my %xmlheader = $xmlviewer->GetInfo;
Elements for XMLdecl: Version Encoding Standalone Elements for DOCTYPE: Name Sysid Pubid Internal
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?)
Slaven Rezic, <slaven@rezic.de>
Some additions by Jerry Geiger <jgeiger@rios.de>.
the XML::Parser manpage(3), the Tk::Text manpage(3).
Tk::XMLViewer - Tk widget to display XML |