Site menu:

Back to examples

Perl Example - Check if XML is well formed or not

#################################################
#Version 0.1                                    #
#Free to use for any purpose                    #
#No credits or backlink required                #
#Author : Shaji Kalidasan (shajiindia@yahoo.com)#
#################################################

use XML::Parser;

my $parser = XML::Parser->new;
my $xml = 'players.xml'; #Supply your XML file here

eval { $parser->parsefile($xml) };

if ($@) {  
  print "XML is not well formed.\n";
} else {  
  print "XML is well formed.\n";
}