GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
XMLViewer(3) User Contributed Perl Documentation XMLViewer(3)

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:
-tagcolor => $color
Foreground color of tags.
-attrkeycolor => $color
Foreground color of attribute keys.
-attrvalcolor => $color
Foreground color of attribute values.
-commentcolor => $color
Foreground color of comment sections.

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");

insertXML
Insert XML into the XMLViewer widget. Use the -file argument to insert a file and -text to insert an XML string. A hash to the -xmlparserargs option will be passed to the XML::Parser constructor.
DumpXML
Dump the contents of an "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;
    
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

Perl/Tk 804 has Unicode support, so has "Tk::XMLViewer".

Perl/Tk 800 does not support Unicode. In this case "Tk::XMLViewer" tries to translate all characters returned by the XML parser to the "iso-8859-1" charset. This may be done with a builtin function like "pack"/"unpack" or a CPAN module like Unicode::String. If no fallback could be found, then Unicode characters 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.

 - show to depth n: close everything from depth n+1
 - create menu item "close selected region"
 - DTD validation (is this possible with XML::Parser?)
 - use alternative XML parser i.e. XML::LibXML::Reader (maybe this
   would be faster?)

Slaven Rezic, <slaven@rezic.de>

Some additions by Jerry Geiger <jgeiger@rios.de>.

XML::Parser, Tk::Text, tkxmlview.
2009-11-10 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.