XML, the Perl Way


NAME

XML::DOM::Twig - a perl module that adds an XML::Twig like interface to XML::DOM


SYNOPSYS

  use XML::DOM;
  use TwigDOM;
  my $parser = new XML::DOM::Parser;
  my $doc = $parser->parsefile( "doc.xml");
  my $root= $doc->root;               # the DOM method is getDocumentElement
  my $para= $root->next_elt( 'para'); # adds a condition to DOM's getNextSibling


DESCRIPTION

The DOM is a standard interface to XML documents, but it is very low-level, not to mention down right ugly, at least as implemented in XML::DOM.

XML::DOM::Twig adds nicer (and more perlish) method names, plus a whole slew of extra methods,most of them straight out of XML::Twig, that makes it easier and safer to use it.

XML::DOM::Twig navigation functions for example accept an extra condition that makes it easy to specify what the tag of the next element should be, instead of either hoping that DOM methods will return the right one (they won't!) or having to write a similar function yourself.


METHODS

XML::DOM::Node

cond

Most of the navigation functions accept a condition as an optional argument The first element (or all elements for children or ancestors) that passes the condition is returned.

The condition can be

#ELT
return a ``real'' element (not a PCDATA, CDATA, comment or pi element)

#TEXT
return a PCDATA or CDATA element

string
return an element whose gi is equal to the string

regular expression
return an element whose gi matches the regexp. The regexp has to be created with qr// (hence this is available only on perl 5.005 and above)

code reference
applies the code, passing the current element as argument, if the code returns true then the element is returned, if it returns false then the code is applied to the next candidate.

XML::DOM::Document


AUTHOR

Michel Rodriguez <m.v.rodriguez@ieee.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Bug reports and comments to m.v.rodriguez@ieee.org.

The XML::DOM::Twig web site is http://www.xmltwig.org/domtwig/


SEE ALSO

XML::Parser XML::DOM XML::Twig

The XML::Twig page is at http://www.xmltwig.org/xmltwig/ It includes examples and a tutorial at http://www.xmltwig.org/xmltwig/tutorial/index.html