Skip to content
XML, the Perl way
Perl
Find file
Latest commit 9e48048 Oct 5, 2014 @mirod re fix for RT #97461
Failed to load latest commit information.
Twig Hide monkey patching from PAUSE Jul 18, 2014
t fixed and tested https://rt.cpan.org/Ticket/Display.html?id=98801 inc… Oct 5, 2014
tools cleanup, stuff that had not been commited previously May 22, 2014
~ cleanup, stuff that had not been commited previously May 22, 2014
.gitignore cleanup, stuff that had not been commited previously May 22, 2014
Changes fixed and added credits to Changes Oct 5, 2014
MANIFEST fixed RT # 96009 May 27, 2014
META.json cleanup, stuff that had not been commited previously May 22, 2014
META.yml cleanup, stuff that had not been commited previously May 22, 2014
MYMETA.json cleanup, stuff that had not been commited previously May 22, 2014
Makefile.PL last changes before 3.45 Mar 1, 2014
README more tests May 1, 2012
Twig.pm cleanup, stuff that had not been commited previously May 22, 2014
Twig_pm.slow re fix for RT #97461 Oct 5, 2014
XML-Twig-FAQ.html cleanup, stuff that had not been commited previously May 22, 2014
check_optional_modules refactored used_perl to get the Devel::Cover flag added to it when ne… Sep 21, 2010
cover_twig added the -i option (incremental: do not delete the coverage db) Nov 15, 2012
doc_latin1.xml YAIC Aug 24, 2009
doc_utf8.xml YAIC Aug 24, 2009
faq.html cleanup, stuff that had not been commited previously May 22, 2014
faq.xml replaced xmltwig.com by xmltwig.org in the docs Sep 21, 2011
filter_for_5.005 YAIC Aug 24, 2009
group_changes cleanup, stuff that had not been commited previously May 22, 2014
html2xml YAIC Aug 24, 2009
list_deps cleanup, stuff that had not been commited previously May 22, 2014
my_pod2html fixed formating Jan 15, 2010
new_changes cleanup, stuff that had not been commited previously May 22, 2014
old_changes cleanup, stuff that had not been commited previously May 22, 2014
parse_random_files cleanup, stuff that had not been commited previously May 22, 2014
speedup cleanup, stuff that had not been commited previously May 22, 2014
test_uri cleanup, stuff that had not been commited previously May 22, 2014
tmp_file cleanup, stuff that had not been commited previously May 22, 2014
twig_faq replaced xmltwig.com by xmltwig.org in the docs Sep 21, 2011
upd_changes cleanup, stuff that had not been commited previously May 22, 2014
upd_twig more tests, fixes to _add_or_discard_stored_spaces Dec 3, 2012

README

NAME

    XML::Twig - Tree interface to XML documents allowing processing chunk
                by chunk of huge documents.

                

SUMMARY (see perldoc XML::Twig for full details)

XML::Twig is (yet another!) XML transformation module. 

Its strong points: can be used to process huge documents while still
being in tree mode; not bound by DOM or SAX, so it is very perlish and
offers a very comprehensive set of methods; simple to use; DWIMs as
much as possible

What it doesn't offer: full SAX support (it can export SAX, but only
reads XML), full XPath support (unless you use XML::Twig::XPath), nor
DOM support.

Other drawbacks: it is a big module, and with over 500 methods available
it can be a bit overwhelming. A good starting point is the tutorial at
http://xmltwig.org/xmltwig/tutorial/index.html. In fact the whole
XML::Twig page at http://xmltwig.org/xmltwig/ has plenty of information
to get you started with XML::Twig

TOOLS

XML::Twig comes with a few tools built on top of it:

  xml_pp           XML pretty printer
  xml_grep         XML grep - grep XML files using XML::Twig's subset of XPath
  xml_split        split big XML files
  xml_merge        merge back files created by xml_split
  xml_spellcheck   spellcheck XML files skipping tags

Running perl Makefile.PL will prompt you for each tool installation. 
  perl Makefile.PL -y     will install all of the tools without prompt
  perl Makefile.PL -n     will skip the installation of the tools


SYNOPSYS

  single-tree mode    
    my $t= XML::Twig->new();
    $t->parsefile( 'doc.xml');
    $t->print;

  chunk mode 
    # print the document, at most one full section is loaded in memory
    my $t= XML::Twig->new( twig_handlers => { section => \&flush});
    $t->parsefile( 'doc.xml');
    $t->flush;
    sub flush { (my $twig, $section)= @_; $twig->flush; }
    
  sub-tree mode 
    # print all section title's in the document,
    # all other elements are ignored (and not stored)
    my $t= XML::Twig->new( 
            twig_roots => { 'section/title' => sub { $_->print, "\n" } }
                         );
    $t->parsefile( 'doc.xml');
    
INSTALLATION

    perl Makefile.PL
    make
    make test
    make install

DEPENDENCIES

    XML::Twig needs XML::Parser (and the expat library) installed
   
    Modules that can enhance XML::Twig are:

    Scalar::Util or WeakRef 
      to avoid memory leaks
    Encode or Text::Iconv or Unicode::Map8 and Unicode::Strings 
      to do encoding conversions
    Tie::IxHash 
      to use the keep_atts_order option
    XML::XPathEngine 
      to use XML::Twig::XPath
    LWP 
      to use parseurl
    HTML::Entities
      to use the html_encode filter
    HTML::TreeBuilder
      to process HTML instead of XML

CHANGES

    See the Changes file    

AUTHOR

    Michel Rodriguez (mirod@cpan.org)
    The Twig page is at http://www.xmltwig.org/xmltwig
    git project repository: http://github.com/mirod/xmltwig
    See the XML::Twig tutorial at http://www.xmltwig.org/xmltwig/tutorial/index.html

COPYRIGHT

       Copyright (c) 1999-2012, Michel Rodriguez. All Rights Reserved.
       This library is free software; you can redistribute it and/or modify
       it under the same terms as Perl itself.
Something went wrong with that request. Please try again.