Monks,

How do I determine the version of XML::Twig installed on my machine. The top line from "perldoc XML::Twig" says:

.0::XML::Twig(3User Contributed Perl Documentatio.0::XML::Twig(3)
and I am running perl v5.6.0. I want to guess it Twig version 3.XX but I don't know what XX should be.

My immediate challenge my installation cannot do:

$twig->set_doctype(...)

The error is

Can't locate object method "set_doctype" via package "XML::Twig"
Sample Perl Program:
#!/usr/bin/perl use strict; use XML::Twig; my $twig= new XML::Twig(TwigHandlers => { servlet => \&servletTag }, comments => "keep" ); $twig->set_pretty_print( "indented"); # parse the twig $twig->parsefile( "web.xml"); $twig->set_doctype("test", "test", "test", "test"); $twig->print(); sub servletTag { my $LOCALE = "es_US"; my( $twig, $servlet)= @_; my $jspFileTag= $servlet->first_child("jsp-file");; if (defined($jspFileTag)) { my $path = $jspFileTag->text(); my $LOCALE_MOD = "/$LOCALE/"; if ( $path =~ /$LOCALE_MOD/ ) { $servlet->cut(); return; } } }
Sample XML File
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3// +EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <!-- This is my comment --> <web-app> <servlet> <servlet-name>Authenticate_en_US</servlet-name> <jsp-file>/vxml/en_US/type_0/entry/Authenticate.jsp</jsp-file> <load-on-startup>2</load-on-startup> </servlet> <servlet> <servlet-name>Authenticate_es_US</servlet-name> <jsp-file>/vxml/es_US/type_0/entry/Authenticate.jsp</jsp-file> <load-on-startup>2</load-on-startup> </servlet> </web-app>

In reply to Determining Installed Twig Version by gjeffrey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.