The reason why 1 cannot be mistaken for an element name is that element names cannot start with digits. Use "a" and "b" with the following XML to see what is matched against what:
#!/usr/bin/perl
use warnings;
use strict;
use XML::LibXML;
my $tree = 'XML::LibXML'->load_xml(string => <<'EOT');
<?xml version="1.0"?>
<language>
<english>
<widget ID="a">input</widget>
<widget ID="b">output</widget>
</english>
<deutsch>
<widget ID="b">
eingabe
<b>b</b>
</widget>
<widget ID="b">ausgabe</widget>
</deutsch>
</language>
EOT
test('english', 'a');
test('deutsch', 'b');
sub test {
my ($language,$id) = @_;
my @result = $tree->findnodes("/language/$language/widget[\@ID=$id
+]");
print $_->textContent . "\n" for @result;
my @result2 = $tree->findnodes("/language/$language/widget[\@ID='$
+id']");
print $_->textContent . "\n" for @result2;
}
|