Subject: | Ancestor function |
I found a small bug in the ancestor function of Writer. I don't even understand why it is happening .... this is the code I am using to create a simple Xpath to where the writer is. I can't seem to figure out why it adds the same element twice... here is a simple script that shows the bug.
use XML::Writer;
use IO::File;
use strict;
my $output = new IO::File(">test.xml");
my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT => 1);
$writer->startTag("ROOT");
$writer->startTag("NODE1");
$writer->startTag("NODE2");
my $n = 0;
my $xpath;
while ($writer->ancestor($n)) {
$xpath = "/" . $writer->ancestor($n) . $xpath;
print "$n -- " . $writer->ancestor($n) . " -- $xpath\n";
$n++;
}
$writer->endTag();
$writer->endTag();
$writer->endTag();
$writer->end();
$output->close();