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


Manual Reference Pages  -  XML::LIBERAL (3)

.ds Aq ’

NAME

XML::Liberal - Super liberal XML parser that parses broken XML

CONTENTS

SYNOPSIS



  use XML::Liberal;

  my $parser = XML::Liberal->new(LibXML);
  my $doc = $parser->parse_string($broken_xml);

  # or, override XML::LibXML->new globally
  use XML::LibXML;
  use XML::Liberal;

  XML::Liberal->globally_override(LibXML);
  my $parser = XML::LibXML->new; # isa XML::Liberal

  # revert the global overrides back
  XML::Liberal->globally_unoverride(LibXML);

  # override XML::LibXML->new globally in a lexical scope
  {
     my $destructor = XML::LibXML->globally_override(LibXML);
     my $parser = XML::LibXML->new; # isa XML::Liberal
  }

  # $destructor goes out of scope and global override doesnt take effect
  my $parser = XML::LibXML->new; # isa XML::LibXML



DESCRIPTION

XML::Liberal is a super liberal XML parser that can fix broken XML stream and create a DOM node out of it.

<B>This module is ALPHA SOFTWAREB> and its API and internal class layouts etc. are subject to change later.

METHODS

new


  $parser = XML::Liberal->new(LibXML);



Creates an XML::Liberal object. Currently accepted driver is only LibXML.

globally_override


  XML::Liberal->globally_override(LibXML);



Override XML::LibXML’s new method globally, to create XML::Liberal object instead of XML::LibXML parser.

This is considered <B>so evilB>, but would be useful if you have existent software/library that uses XML::LibXML inside and change the behaviour globally to use Liberal parser instead, with a single method call.

For example, the following code lets XML::Atom’s parser use Liberal LibXML parser.



  use URI;
  use XML::Atom::Feed;
  use XML::Liberal;

  XML::Liberal->globally_override(LibXML);

  # XML::Atom calls XML::LibXML->new, which is aliased to Liberal now
  my $feed = XML::Atom::Feed->new(URI->new(http://example.com/atom.xml));



If you want the original XML::LibXML->new back in business, you can call globally_unoverride method.



  XML::Liberal->globally_override(LibXML);
  # ... do something
  XML::Liberal->globally_unoverride(LibXML);



Or, you can hold the destructor object in a scalar variable and make the global override take effect only in a lexical scope:



  {
    my $destructor = XML::Liberal->globally_override(LibXML);
    # ... do something
  }

  # now XML::LibXML::new is back as normal



BUGS

This module tries to fix the XML data in various ways, some of which might alter your XML content, especially bytes written in CDATA.

AUTHOR

Tatsuhiko Miyagawa <miyagawa@bulknews.net>

Aaron Crane

LICENSE

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

SEE ALSO

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


perl v5.20.3 XML::LIBERAL (3) 2013-01-25

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