Subject: | Validate XML using LibXML - XSD - line and column number |
Dear,
I am working on XP machine. That is my programme :
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
my $FichierXML = 'filetest.xml';
my $parser = XML::LibXML->new();
my $tree = $parser->parse_file($FichierXML);
my $root = $tree->getDocumentElement;
# Validation XSD du fichier XML
# Récupérons le fichier XSD dans la balise annuaire
my $FichierXSD = $root->getAttribute('xsi:noNamespaceSchemaLocation');
my $schema = XML::LibXML::Schema->new( location => $FichierXSD );
eval { $schema->validate($tree) };
die "[XSD] Le fichier $FichierXML est non valide.\n$@" if $@;
I am using the XML::LibXML perl module to validate an XML file against a defined XML schema. When the file fails to validate, I will get a list of errors informing me.In my XML file I will have many elements of the same name but they may be nested in various places in the XML file.
How can I get the lines number and column number of each error in the XML file ?
Best regards,
Djibel