Tk::Tree::XML - XML tree widget
use Tk::Tree::XML; $top = MainWindow->new; $xml_tree = $top->XML(?options?); $xml_tree = $top->ScrolledXML(?options?); $xml_tree->load_xml_file("file.xml"); $xml_tree->load_xml_string('<root><child /></root>');
XML graphically displays the tree structure of XML documents loaded from either an XML file or an XML string.
XML enables Perl/Tk applications with a widget that allows visual representation and interaction with XML document trees.
Target applications may include XML viewers, editors and the like.
XML is a subclass of Tk::Tree and therefore inherits all of its standard options.
Details on standard widget options can be found at Tk::options.
Set the maximum number of characters to be displayed for PCDATA elements. Content of such elements is trimmed to a length of pcdataMaxLength characters.
Default value: 80.
80
Set the symbol to append to PCDATA content with length greater than pcdataMaxLength characters.
Default value: ....
...
Specify whether space characters surrounding PCDATA elements should be preserved or not. Such characters are preserved if this option is set to 1 and not preserved if set to 0.
Default value: 0.
The XML method creates a widget object. This object supports the configure and cget methods described in Tk::options which can be used to enquire and modify the options described above. The widget also inherits all the methods provided by the generic Tk::Widget class.
An XML is not scrolled by default. The ScrolledXML method creates a scrolled XML.
The following additional methods are available for XML widgets:
Load an XML document from a file into the tree. If the tree is already loaded with an XML document, no reloading occurs and a warning message is issued.
Return value: none.
Example(s):
# load XML document from file document.xml into the tree $xml_tree->load_xml_file('document.xml');
Load an XML document represented by a string into the tree. If the tree is already loaded with an XML document, no reloading occurs and a warning message is issued.
# load XML document from xml string into the tree $xml_tree->load_xml_string('<root><child /></root>');
Retrieve the name of the currently selected XML element.
Return value: name of selected element if it is mixed, undef if it is PCDATA.
# retrieve name of currently selected element $element_name = $xml_tree->get_name();
Retrieve the attribute list of the currently selected XML element.
Return value: attributes of selected element if it is mixed, undef if it is PCDATA. Attributes are returned as an associative array, where each key/value pair represent an attribute name/value, respectively.
# retrieve attribute list of currently selected element %attributes = $xml_tree->get_attrs();
Retrieve the content of the currently selected XML element.
Return value: Text content if selected element is PCDATA, undef if it is mixed.
# retrieve content text of currently selected element $text = $xml_tree->get_text();
Indicate whether the currently selected element is mixed or not. If the element is not mixed then it is PCDATA.
Return value: TRUE if the currently selected element is mixed, FALSE if it is PCDATA.
# determine if selected element is mixed or not print "element is " . ($xml_tree->is_mixed() ? 'mixed' : 'PCDATA');
Indicate whether the currently selected element is PCDATA or not. If the element is not PCDATA then it is mixed.
Return value: TRUE if the currently selected element is PCDATA, FALSE if it is mixed.
# determine if selected element is PCDATA or not print "element is " . ($xml_tree->is_pcdata() ? 'PCDATA' : 'mixed');
An XML viewer using Tk::Tree::XML can be found in the examples directory included with this module.
Tk::Tree::XML version 0.01.
Santos, José.
Please report any bugs or feature requests to bug-tk-tree-xml at rt.cpan.org or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tk-Tree-XML. The author will be notified and there will be automatic notification about progress on bugs as changes are made.
bug-tk-tree-xml at rt.cpan.org
Documentation for this module can be found with the following perldoc command:
perldoc Tk::Tree::XML
Additional information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Tk-Tree-XML
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Tk-Tree-XML
CPAN Ratings
http://cpanratings.perl.org/d/Tk-Tree-XML
Search CPAN
http://search.cpan.org/dist/Tk-Tree-XML
Copyright (c) 2008 José Santos. All rights reserved.
This program is free software. It can redistributed and/or modified under the same terms as Perl itself.
Thanks to Cotonete, Droit, Pistacho and Barriguita.
I dedicate Tk::Tree::XML to my GrandMother.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'José.'. Assuming CP1252
To install Tk::Tree::XML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::Tree::XML
CPAN shell
perl -MCPAN -e shell install Tk::Tree::XML
For more information on module installation, please visit the detailed CPAN module installation guide.